Python matplotlib.pyplot.rcdefaults() Examples

The following are 9 code examples of matplotlib.pyplot.rcdefaults(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.pyplot , or try the search function .
Example #1
Source File: dataturks_graph.py    From douglas-quaid with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #2
Source File: energyplus_model.py    From rl-testbed-for-energyplus with MIT License 6 votes vote down vote up
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 
Example #3
Source File: scrapers.py    From sphinx-gallery with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _reset_matplotlib(gallery_conf, fname):
    """Reset matplotlib."""
    _, plt = _import_matplotlib()
    plt.rcdefaults() 
Example #4
Source File: prettyplot.py    From uncertainpy with GNU General Public License v3.0 5 votes vote down vote up
def reset_style():
    plt.rcdefaults() 
Example #5
Source File: analyze.py    From rally with Apache License 2.0 5 votes vote down vote up
def create_plot():
    plt.rcdefaults()
    fig, ax = plt.subplots()
    fig.set_size_inches(18, 10)
    return fig, ax 
Example #6
Source File: analysis.py    From twitter-intelligence with MIT License 5 votes vote down vote up
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() 
Example #7
Source File: driverlessCityProject_spatialPointsPattern_association_corr.py    From python-urbanPlanning with MIT License 5 votes vote down vote up
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 
Example #8
Source File: generate_graph.py    From deepchem with MIT License 4 votes vote down vote up
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() 
Example #9
Source File: energyplus_model.py    From rl-testbed-for-energyplus with MIT License 4 votes vote down vote up
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()