當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。