當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.rcdefaults方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.rcdefaults方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.rcdefaults方法的具體用法?Python pyplot.rcdefaults怎麽用?Python pyplot.rcdefaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.rcdefaults方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: draw_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def draw_plot(labels, value, save_path: pathlib.Path, log_scale=False):
        # Fixing random state for reproducibility
        np.random.seed(19680801)

        plt.rcdefaults()
        fig, ax = plt.subplots()

        # Example data
        # people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
        y_pos = np.arange(len(labels))
        # performance = 3 + 10 * np.random.rand(len(people))
        # error = np.random.rand(len(people))

        ax.barh(y_pos, value, align='center')
        ax.set_yticks(y_pos)
        ax.set_yticklabels(labels)
        if log_scale:
            ax.set_xscale('log')
        ax.invert_yaxis()  # labels read top-to-bottom
        ax.set_xlabel('Nb items')
        ax.set_title('How many items per cluster')

        plt.savefig(save_path)
        plt.show() 
開發者ID:CIRCL,項目名稱:douglas-quaid,代碼行數:26,代碼來源:dataturks_graph.py

示例2: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def plot(self, log_dir='', csv_file='', **kwargs):
        if log_dir is not '':
            if not os.path.isdir(log_dir):
                print('energyplus_model.plot: {} is not a directory'.format(log_dir))
                return
            print('energyplus_plot.plot log={}'.format(log_dir))
            self.log_dir = log_dir
            self.show_progress()
        else:
            if not os.path.isfile(csv_file):
                print('energyplus_model.plot: {} is not a file'.format(csv_file))
                return
            print('energyplus_model.plot csv={}'.format(csv_file))
            self.read_episode(csv_file)
            plt.rcdefaults()
            plt.rcParams['font.size'] = 6
            plt.rcParams['lines.linewidth'] = 1.0
            plt.rcParams['legend.loc'] = 'lower right'
            self.fig = plt.figure(1, figsize=(16, 10))
            self.plot_episode(csv_file)
            plt.show()

    # Show convergence 
開發者ID:IBM,項目名稱:rl-testbed-for-energyplus,代碼行數:25,代碼來源:energyplus_model.py

示例3: _reset_matplotlib

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def _reset_matplotlib(gallery_conf, fname):
    """Reset matplotlib."""
    _, plt = _import_matplotlib()
    plt.rcdefaults() 
開發者ID:sphinx-gallery,項目名稱:sphinx-gallery,代碼行數:6,代碼來源:scrapers.py

示例4: reset_style

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def reset_style():
    plt.rcdefaults() 
開發者ID:simetenn,項目名稱:uncertainpy,代碼行數:4,代碼來源:prettyplot.py

示例5: create_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def create_plot():
    plt.rcdefaults()
    fig, ax = plt.subplots()
    fig.set_size_inches(18, 10)
    return fig, ax 
開發者ID:elastic,項目名稱:rally,代碼行數:7,代碼來源:analyze.py

示例6: analysis_hashtag

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def analysis_hashtag():
    with sqlite3.connect(db_path) as db:
        conn = db
        c = conn.cursor()
        c.execute("SELECT hashtag from Tweet")
        hashtag_list = []
        for row in c.fetchall():
            if (row != ('',)):
                if " " in ''.join(row):
                    for m in ''.join(row).split(' '):
                        hashtag_list.append(m)
                else:
                    signle_item = ''.join(row)
                    hashtag_list.append(signle_item)

        counter = Counter(hashtag_list).most_common(10)
        pl.rcdefaults()

        keys = []
        performance = []

        for i in counter:
            performance.append(i[1])
            keys.append(i[0])

        pl.rcdefaults()
        y_pos = np.arange(len(keys))
        error = np.random.rand(len(keys))

        pl.barh(y_pos, performance, xerr=error, align='center', alpha=0.4, )
        pl.yticks(y_pos, keys)
        pl.xlabel('quantity')
        pl.title('hashtags')
        print(colored("[INFO] Showing graph of hashtag analysis", "green"))
        pl.show() 
開發者ID:batuhaniskr,項目名稱:twitter-intelligence,代碼行數:37,代碼來源:analysis.py

示例7: correlation_graph

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def correlation_graph(df,xlabel_str,title_str):
    plt.clf()
    corr =df.corr() 
    # print("_"*50,"correlation:")
    # print(corr)
    
    #01-correlation heatmap
    sns.set()
    f, ax = plt.subplots(figsize=(10*4.5, 10*4.5))
    sns.heatmap(corr, annot=True, fmt=".2f", linewidths=.5, ax=ax)
    
    #02-bar plot
    indicatorName=corr.columns.to_numpy()
    # plt.clf()
    plt.rcdefaults()
    plt.rcParams.update({'font.size':14})
    fig, ax = plt.subplots(figsize=(10*2, 10*2))  
    y_pos = np.arange(len(indicatorName))
    error = np.random.rand(len(indicatorName))
    
    ax.barh(y_pos, corr.PHMI.to_numpy(), align='center') #xerr=error, 
    ax.set_yticks(y_pos)
    ax.set_yticklabels(indicatorName)
    ax.invert_yaxis()  # labels read top-to-bottom
    ax.set_xlabel(xlabel_str)
    ax.set_title(title_str)
    for index, value in enumerate(corr.PHMI.to_numpy()):
        plt.text(value, index, str(round(value,2)))
    plt.show()
    
    return corr

#plot multiple curve 
開發者ID:richieBao,項目名稱:python-urbanPlanning,代碼行數:35,代碼來源:driverlessCityProject_spatialPointsPattern_association_corr.py

示例8: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def plot(dataset, split, path, out_path):
  if dataset in [
      'bace_c', 'bbbp', 'clintox', 'hiv', 'muv', 'pcba', 'pcba_146',
      'pcba_2475', 'sider', 'tox21', 'toxcast'
  ]:
    mode = 'classification'
  else:
    mode = 'regression'
  data = {}
  with open(path, 'r') as f:
    reader = csv.reader(f)
    for line in reader:
      if line[0] == dataset and line[1] == split:
        data[line[3]] = line[8]
  labels = []
  values = []
  colors = []
  for model in ORDER:
    if model in data.keys():
      labels.append(model)
      colors.append(COLOR[model])
      values.append(float(data[model]))
  y_pos = np.arange(len(labels))
  plt.rcdefaults()
  fig, ax = plt.subplots()

  ax.barh(y_pos, values, align='center', color='green')
  ax.set_yticks(y_pos)
  ax.set_yticklabels(labels)
  ax.invert_yaxis()
  if mode == 'regression':
    ax.set_xlabel('R square')
    ax.set_xlim(left=0., right=1.)
  else:
    ax.set_xlabel('ROC-AUC')
    ax.set_xlim(left=0.4, right=1.)
  t = time.localtime(time.time())
  ax.set_title("Performance on %s (%s split), %i-%i-%i" %
               (dataset, split, t.tm_year, t.tm_mon, t.tm_mday))
  plt.tight_layout()
  for i in range(len(colors)):
    ax.get_children()[i].set_color(colors[i])
    ax.text(
        values[i] - 0.1, y_pos[i] + 0.1, str("%.3f" % values[i]), color='white')
  fig.savefig(os.path.join(out_path, dataset + '_' + split + '.png'))
  #plt.show() 
開發者ID:deepchem,項目名稱:deepchem,代碼行數:48,代碼來源:generate_graph.py

示例9: show_progress

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rcdefaults [as 別名]
def show_progress(self):
        self.monitor_file = self.log_dir + '/monitor.csv'

        # Read progress file
        if not self.read_monitor_file():
            print('Progress data is missing')
            sys.exit(1)

        # Initialize graph
        plt.rcdefaults()
        plt.rcParams['font.size'] = 6
        plt.rcParams['lines.linewidth'] = 1.0
        plt.rcParams['legend.loc'] = 'lower right'

        self.fig = plt.figure(1, figsize=(16, 10))

        # Show widgets
        axcolor = 'lightgoldenrodyellow'
        self.axprogress = self.fig.add_axes([0.15, 0.10, 0.70, 0.15], facecolor=axcolor)
        self.axslider = self.fig.add_axes([0.15, 0.04, 0.70, 0.02], facecolor=axcolor)
        axfirst = self.fig.add_axes([0.15, 0.01, 0.03, 0.02])
        axlast = self.fig.add_axes([0.82, 0.01, 0.03, 0.02])
        axprev = self.fig.add_axes([0.46, 0.01, 0.03, 0.02])
        axnext = self.fig.add_axes([0.51, 0.01, 0.03, 0.02])

        # Slider is drawn in plot_progress()

        # First/Last button
        self.button_first = Button(axfirst, 'First', color=axcolor, hovercolor='0.975')
        self.button_first.on_clicked(self.first_episode_num)
        self.button_last = Button(axlast, 'Last', color=axcolor, hovercolor='0.975')
        self.button_last.on_clicked(self.last_episode_num)

        # Next/Prev button
        self.button_prev = Button(axprev, 'Prev', color=axcolor, hovercolor='0.975')
        self.button_prev.on_clicked(self.prev_episode_num)
        self.button_next = Button(axnext, 'Next', color=axcolor, hovercolor='0.975')
        self.button_next.on_clicked(self.next_episode_num)

        # Timer
        self.timer = self.fig.canvas.new_timer(interval=1000)
        self.timer.add_callback(self.check_update)
        self.timer.start()

        # Progress data
        self.axprogress.set_xmargin(0)
        self.axprogress.set_xlabel('Episodes')
        self.axprogress.set_ylabel('Reward')
        self.axprogress.grid(True)
        self.plot_progress()

        # Plot latest episode
        self.update_episode(self.num_episodes - 1)

        plt.show() 
開發者ID:IBM,項目名稱:rl-testbed-for-energyplus,代碼行數:57,代碼來源:energyplus_model.py


注:本文中的matplotlib.pyplot.rcdefaults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。