Python matplotlib.rc() Examples
The following are 30
code examples of matplotlib.rc().
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
, or try the search function
.
Example #1
Source File: utils.py From pruning_yolov3 with GNU General Public License v3.0 | 7 votes |
def plot_evolution_results(hyp): # from utils.utils import *; plot_evolution_results(hyp) # Plot hyperparameter evolution results in evolve.txt x = np.loadtxt('evolve.txt', ndmin=2) f = fitness(x) weights = (f - f.min()) ** 2 # for weighted results fig = plt.figure(figsize=(12, 10)) matplotlib.rc('font', **{'size': 8}) for i, (k, v) in enumerate(hyp.items()): y = x[:, i + 5] # mu = (y * weights).sum() / weights.sum() # best weighted result mu = y[f.argmax()] # best single result plt.subplot(4, 5, i + 1) plt.plot(mu, f.max(), 'o', markersize=10) plt.plot(y, f, '.') plt.title('%s = %.3g' % (k, mu), fontdict={'size': 9}) # limit to 40 characters print('%15s: %.3g' % (k, mu)) fig.tight_layout() plt.savefig('evolve.png', dpi=200)
Example #2
Source File: pyplot.py From Computable with MIT License | 7 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example #3
Source File: pyplot.py From neural-network-animation with MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example #4
Source File: pyplot.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap)
Example #5
Source File: pyplot.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None): """ Tune the subplot layout. The parameter meanings (and suggested defaults) are:: left = 0.125 # the left side of the subplots of the figure right = 0.9 # the right side of the subplots of the figure bottom = 0.1 # the bottom of the subplots of the figure top = 0.9 # the top of the subplots of the figure wspace = 0.2 # the amount of width reserved for space between subplots, # expressed as a fraction of the average axis width hspace = 0.2 # the amount of height reserved for space between subplots, # expressed as a fraction of the average axis height The actual defaults are controlled by the rc file """ fig = gcf() fig.subplots_adjust(left, bottom, right, top, wspace, hspace)
Example #6
Source File: simple_functions.py From Ensemble-Bayesian-Optimization with MIT License | 6 votes |
def plot_f(f, filenm='test_function.eps'): # only for 2D functions import matplotlib.pyplot as plt import matplotlib font = {'size': 20} matplotlib.rc('font', **font) delta = 0.005 x = np.arange(0.0, 1.0, delta) y = np.arange(0.0, 1.0, delta) nx = len(x) X, Y = np.meshgrid(x, y) xx = np.array((X.ravel(), Y.ravel())).T yy = f(xx) plt.figure() plt.contourf(X, Y, yy.reshape(nx, nx), levels=np.linspace(yy.min(), yy.max(), 40)) plt.xlim([0, 1]) plt.ylim([0, 1]) plt.colorbar() plt.scatter(f.argmax[0], f.argmax[1], s=180, color='k', marker='+') plt.savefig(filenm)
Example #7
Source File: pyplot.py From neural-network-animation with MIT License | 6 votes |
def subplots_adjust(*args, **kwargs): """ Tune the subplot layout. call signature:: subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) The parameter meanings (and suggested defaults) are:: left = 0.125 # the left side of the subplots of the figure right = 0.9 # the right side of the subplots of the figure bottom = 0.1 # the bottom of the subplots of the figure top = 0.9 # the top of the subplots of the figure wspace = 0.2 # the amount of width reserved for blank space between subplots hspace = 0.2 # the amount of height reserved for white space between subplots The actual defaults are controlled by the rc file """ fig = gcf() fig.subplots_adjust(*args, **kwargs) draw_if_interactive()
Example #8
Source File: generate_is_plot.py From big-discriminator-batch-spoofing-gan with MIT License | 6 votes |
def generate_plot(x, y, title, save_path): """ generates the plot given the indices and is values :param x: the indices (epochs) :param y: IS values :param title: title of the generated plot :param save_path: path to save the file :return: None (saves file) """ font = {'family': 'normal', 'size': 20} matplotlib.rc('font', **font) plt.figure(figsize=(10, 6)) annot_max(x, y) plt.margins(.05, .05) plt.title(title) plt.xlabel("Epochs") plt.ylabel("Inception scores") plt.ylim(0, max(y) + 2) plt.plot(x, y, linewidth=4) plt.tight_layout() plt.savefig(save_path, bbox_inches='tight')
Example #9
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 6 votes |
def set_cmap(cmap): """ Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.get_cmap`. """ cmap = cm.get_cmap(cmap) rc('image', cmap=cmap.name) im = gci() if im is not None: im.set_cmap(cmap) draw_if_interactive()
Example #10
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 6 votes |
def subplots_adjust(*args, **kwargs): """ Tune the subplot layout. call signature:: subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) The parameter meanings (and suggested defaults) are:: left = 0.125 # the left side of the subplots of the figure right = 0.9 # the right side of the subplots of the figure bottom = 0.1 # the bottom of the subplots of the figure top = 0.9 # the top of the subplots of the figure wspace = 0.2 # the amount of width reserved for blank space between subplots hspace = 0.2 # the amount of height reserved for white space between subplots The actual defaults are controlled by the rc file """ fig = gcf() fig.subplots_adjust(*args, **kwargs) draw_if_interactive()
Example #11
Source File: generate_fid_plot.py From big-discriminator-batch-spoofing-gan with MIT License | 6 votes |
def generate_plot(x, y, title, save_path): """ generates the plot given the indices and fid values :param x: the indices (epochs) :param y: fid values :param title: title of the generated plot :param save_path: path to save the file :return: None (saves file) """ font = {'family': 'normal', 'size': 20} matplotlib.rc('font', **font) plt.figure(figsize=(10, 6)) annot_min(x, y) plt.margins(.05, .05) plt.title(title) plt.xlabel("Epochs") plt.ylabel("FID scores") plt.plot(x, y, linewidth=4) plt.tight_layout() plt.savefig(save_path, bbox_inches='tight')
Example #12
Source File: pyplot.py From Computable with MIT License | 6 votes |
def subplots_adjust(*args, **kwargs): """ Tune the subplot layout. call signature:: subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) The parameter meanings (and suggested defaults) are:: left = 0.125 # the left side of the subplots of the figure right = 0.9 # the right side of the subplots of the figure bottom = 0.1 # the bottom of the subplots of the figure top = 0.9 # the top of the subplots of the figure wspace = 0.2 # the amount of width reserved for blank space between subplots hspace = 0.2 # the amount of height reserved for white space between subplots The actual defaults are controlled by the rc file """ fig = gcf() fig.subplots_adjust(*args, **kwargs) draw_if_interactive()
Example #13
Source File: test_rcparams.py From neural-network-animation with MIT License | 6 votes |
def test_rcparams_reset_after_fail(): # There was previously a bug that meant that if rc_context failed and # raised an exception due to issues in the supplied rc parameters, the # global rc parameters were left in a modified state. if sys.version_info[:2] >= (2, 7): from collections import OrderedDict else: raise SkipTest("Test can only be run in Python >= 2.7 as it requires OrderedDict") with mpl.rc_context(rc={'text.usetex': False}): assert mpl.rcParams['text.usetex'] is False with assert_raises(KeyError): with mpl.rc_context(rc=OrderedDict([('text.usetex', True),('test.blah', True)])): pass assert mpl.rcParams['text.usetex'] is False
Example #14
Source File: test_rcparams.py From neural-network-animation with MIT License | 6 votes |
def test_rcparams_update(): if sys.version_info[:2] < (2, 7): raise nose.SkipTest("assert_raises as context manager " "not supported with Python < 2.7") rc = mpl.RcParams({'figure.figsize': (3.5, 42)}) bad_dict = {'figure.figsize': (3.5, 42, 1)} # make sure validation happens on input with assert_raises(ValueError): with warnings.catch_warnings(): warnings.filterwarnings('ignore', message='.*(validate)', category=UserWarning) rc.update(bad_dict) # remove know failure + warnings after merging to master
Example #15
Source File: test_rcparams.py From neural-network-animation with MIT License | 6 votes |
def test_rcparams(): usetex = mpl.rcParams['text.usetex'] linewidth = mpl.rcParams['lines.linewidth'] # test context given dictionary with mpl.rc_context(rc={'text.usetex': not usetex}): assert mpl.rcParams['text.usetex'] == (not usetex) assert mpl.rcParams['text.usetex'] == usetex # test context given filename (mpl.rc sets linewdith to 33) with mpl.rc_context(fname=fname): assert mpl.rcParams['lines.linewidth'] == 33 assert mpl.rcParams['lines.linewidth'] == linewidth # test context given filename and dictionary with mpl.rc_context(fname=fname, rc={'lines.linewidth': 44}): assert mpl.rcParams['lines.linewidth'] == 44 assert mpl.rcParams['lines.linewidth'] == linewidth # test rc_file try: mpl.rc_file(fname) assert mpl.rcParams['lines.linewidth'] == 33 finally: mpl.rcParams['lines.linewidth'] = linewidth
Example #16
Source File: pyplot.py From neural-network-animation with MIT License | 5 votes |
def prism(): ''' set the default colormap to prism and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='prism') im = gci() if im is not None: im.set_cmap(cm.prism) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #17
Source File: generate_multiple_is_plots.py From big-discriminator-batch-spoofing-gan with MIT License | 5 votes |
def generate_plot(xs, ys, titles, save_path): """ generates the plot given the indices and is values :param xs: the indices (epochs) :param ys: IS values :param titles: title of the generated plot :param save_path: path to save the file :return: None (saves file) """ font = {'family': 'normal', 'size': 20} matplotlib.rc('font', **font) plt.figure(figsize=(10, 6)) plt.xlabel("Epochs") plt.ylabel("Inception scores") # set the y limit to 4 + max of everything plt.ylim(0, max(map(max, ys)) + 5) for cnt, x, y, title in zip(range(len(xs)), xs, ys, titles): annot_max(x, y, y_offset=0.96 - (0.07 * cnt)) plt.margins(.05, .05) plt.plot(x, y, linewidth=4, label=title) plt.legend(loc="upper left") plt.tight_layout() plt.savefig(save_path, bbox_inches='tight')
Example #18
Source File: pyplot.py From neural-network-animation with MIT License | 5 votes |
def summer(): ''' set the default colormap to summer and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='summer') im = gci() if im is not None: im.set_cmap(cm.summer) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #19
Source File: pyplot.py From neural-network-animation with MIT License | 5 votes |
def spring(): ''' set the default colormap to spring and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='spring') im = gci() if im is not None: im.set_cmap(cm.spring) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #20
Source File: pyplot.py From neural-network-animation with MIT License | 5 votes |
def winter(): ''' set the default colormap to winter and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='winter') im = gci() if im is not None: im.set_cmap(cm.winter) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #21
Source File: pyplot.py From neural-network-animation with MIT License | 5 votes |
def pink(): ''' set the default colormap to pink and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='pink') im = gci() if im is not None: im.set_cmap(cm.pink) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #22
Source File: generate_multiple_fid_plots.py From big-discriminator-batch-spoofing-gan with MIT License | 5 votes |
def generate_plot(xs, ys, titles, save_path): """ generates the plot given the indices and is values :param xs: the indices (epochs) :param ys: FID values :param titles: title of the generated plot :param save_path: path to save the file :return: None (saves file) """ font = {'family': 'normal', 'size': 20} matplotlib.rc('font', **font) plt.figure(figsize=(10, 6)) plt.xlabel("Epochs") plt.ylabel("FID scores") # set the y limit to 4 + max of everything plt.ylim(0, max(map(max, ys)) + 50) for cnt, x, y, title in zip(range(len(xs)), xs, ys, titles): annot_min(x, y, y_offset=0.96 - (0.07 * cnt)) plt.margins(.05, .05) plt.plot(x, y, linewidth=4, label=title) plt.legend(loc="upper left") plt.tight_layout() plt.savefig(save_path, bbox_inches='tight')
Example #23
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def hsv(): ''' set the default colormap to hsv and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='hsv') im = gci() if im is not None: im.set_cmap(cm.hsv) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #24
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def spectral(): ''' set the default colormap to spectral and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='spectral') im = gci() if im is not None: im.set_cmap(cm.spectral) draw_if_interactive()
Example #25
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def winter(): ''' set the default colormap to winter and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='winter') im = gci() if im is not None: im.set_cmap(cm.winter) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #26
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def spring(): ''' set the default colormap to spring and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='spring') im = gci() if im is not None: im.set_cmap(cm.spring) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #27
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def prism(): ''' set the default colormap to prism and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='prism') im = gci() if im is not None: im.set_cmap(cm.prism) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #28
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def pink(): ''' set the default colormap to pink and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='pink') im = gci() if im is not None: im.set_cmap(cm.pink) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #29
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def jet(): ''' set the default colormap to jet and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='jet') im = gci() if im is not None: im.set_cmap(cm.jet) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost
Example #30
Source File: pyplot.py From matplotlib-4-abaqus with MIT License | 5 votes |
def flag(): ''' set the default colormap to flag and apply to current image if any. See help(colormaps) for more information ''' rc('image', cmap='flag') im = gci() if im is not None: im.set_cmap(cm.flag) draw_if_interactive() # This function was autogenerated by boilerplate.py. Do not edit as # changes will be lost