当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib.rc方法代码示例

本文整理汇总了Python中matplotlib.rc方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.rc方法的具体用法?Python matplotlib.rc怎么用?Python matplotlib.rc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.rc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_evolution_results

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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) 
开发者ID:zbyuan,项目名称:pruning_yolov3,代码行数:20,代码来源:utils.py

示例2: subplots_adjust

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:pyplot.py

示例3: set_cmap

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:pyplot.py

示例4: plot_f

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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) 
开发者ID:zi-w,项目名称:Ensemble-Bayesian-Optimization,代码行数:25,代码来源:simple_functions.py

示例5: generate_plot

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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') 
开发者ID:akanimax,项目名称:big-discriminator-batch-spoofing-gan,代码行数:22,代码来源:generate_fid_plot.py

示例6: generate_plot

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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') 
开发者ID:akanimax,项目名称:big-discriminator-batch-spoofing-gan,代码行数:23,代码来源:generate_is_plot.py

示例7: test_rcparams

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:27,代码来源:test_rcparams.py

示例8: test_rcparams_update

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:19,代码来源:test_rcparams.py

示例9: test_rcparams_reset_after_fail

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:22,代码来源:test_rcparams.py

示例10: subplots_adjust

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:22,代码来源:pyplot.py

示例11: set_cmap

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:pyplot.py

示例12: _check_grid_settings

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
def _check_grid_settings(self, obj, kinds, kws={}):
        # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792

        import matplotlib as mpl

        def is_grid_on():
            xoff = all(not g.gridOn
                       for g in self.plt.gca().xaxis.get_major_ticks())
            yoff = all(not g.gridOn
                       for g in self.plt.gca().yaxis.get_major_ticks())
            return not (xoff and yoff)

        spndx = 1
        for kind in kinds:
            if not _ok_for_gaussian_kde(kind):
                continue

            self.plt.subplot(1, 4 * len(kinds), spndx)
            spndx += 1
            mpl.rc('axes', grid=False)
            obj.plot(kind=kind, **kws)
            assert not is_grid_on()

            self.plt.subplot(1, 4 * len(kinds), spndx)
            spndx += 1
            mpl.rc('axes', grid=True)
            obj.plot(kind=kind, grid=False, **kws)
            assert not is_grid_on()

            if kind != 'pie':
                self.plt.subplot(1, 4 * len(kinds), spndx)
                spndx += 1
                mpl.rc('axes', grid=True)
                obj.plot(kind=kind, **kws)
                assert is_grid_on()

                self.plt.subplot(1, 4 * len(kinds), spndx)
                spndx += 1
                mpl.rc('axes', grid=False)
                obj.plot(kind=kind, grid=True, **kws)
                assert is_grid_on() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:43,代码来源:common.py

示例13: treatment_feature_histogram

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
def treatment_feature_histogram(X,y,feat, names):
	obs = np.array([[0.]*len(X[0])]*2)
	for i in range(0, len(y)):
		obs[y[i]] += X[i]
	colors = ['b', 'r', 'g', 'm', 'k']							# Can plot upto 5 different colors
	pos = np.arange(1, len(obs[0])+1)
	width = 0.1     # gives histogram aspect to the bar diagram
	gridLineWidth=0.1
	fig, ax = plt.subplots()
# 	ax.xaxis.grid(True, zorder=0)
# 	ax.yaxis.grid(True, zorder=0)
	matplotlib.rc('xtick', labelsize=1)
# 	matplotlib.gca().tight_layout()
	for i in range(0, len(obs)):
# 		lbl = "treatment "+str(i)
		plt.bar(pos+i*width, obs[i], width, color=colors[i], alpha=0.5, label=names[i])
# 	plt.bar(pos, obs[0], width, color=colors[0], alpha=0.5)
	plt.xticks(pos+width, feat.data, rotation="vertical")		# useful only for categories
	#plt.axis([-1, len(obs[2]), 0, len(ran1)/2+10])
	plt.ylabel("# agents")
	feat.display()
	print obs[0]
	plt.legend()
	# saving:
	(matplotlib.pyplot).tight_layout()
	fig.savefig("./plots/"+"+".join(names)+".eps")
# 	plt.show() 
开发者ID:tadatitam,项目名称:info-flow-experiments,代码行数:29,代码来源:plot.py

示例14: set_fontsize

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
def set_fontsize(self, font_size):
        """ Updates global font size for all plot elements"""
        mpl.rcParams['font.size'] = font_size
        self.redraw()
        #TODO: Implement individual font size setting
#        params = {'font.family': 'serif',
#          'font.size': 16,
#          'axes.labelsize': 18,
#          'text.fontsize': 18,
#          'legend.fontsize': 18,
#          'xtick.labelsize': 18,
#          'ytick.labelsize': 18,
#          'text.usetex': True}
#        mpl.rcParams.update(params)
    
#    def set_font(self, family=None, weight=None, size=None):
#        """ Updates global font properties for all plot elements
#        
#        TODO: Font family and weight don't update dynamically"""
#        if family is None:
#            family = mpl.rcParams['font.family']
#        if weight is None:
#            weight = mpl.rcParams['font.weight']
#        if size is None:
#            size = mpl.rcParams['font.size']
#        mpl.rc('font', family=family, weight=weight, size=size)
#        self.redraw() 
开发者ID:HamsterHuey,项目名称:easyplot,代码行数:29,代码来源:easyplot.py

示例15: _init_plt

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import rc [as 别名]
def _init_plt(self):
        font = {'family': ['xkcd', 'Humor Sans', 'Comic Sans MS'],
                'weight': 'bold',
                'size': 14}
        matplotlib.rc('font', **font)
        # 这行代码使用「手绘风格图片」,有兴趣小伙伴可以google搜索「xkcd」,有好玩的。
        plt.xkcd()
        self.bar_color = ('#55A868', '#4C72B0', '#C44E52', '#8172B2', '#CCB974', '#64B5CD')
        self.title_font_size = 'x-large' 
开发者ID:newbietian,项目名称:WxConn,代码行数:11,代码来源:main.py


注:本文中的matplotlib.rc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。