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


Python pyplot.rc方法代碼示例

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


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

示例1: dosplot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def dosplot (filename = None, data = None, fermi = None):
    if (filename is not None): data = np.loadtxt(filename)
    elif (data is not None): data = data

    import matplotlib.pyplot as plt
    from matplotlib import rc
    plt.rc('text', usetex=True)
    plt.rc('font', family='serif')
    plt.plot(data.T[0], data.T[1], label='MF Spin-UP', linestyle=':',color='r')
    plt.fill_between(data.T[0], 0, data.T[1], facecolor='r',alpha=0.1, interpolate=True)
    plt.plot(data.T[0], data.T[2], label='QP Spin-UP',color='r')
    plt.fill_between(data.T[0], 0, data.T[2], facecolor='r',alpha=0.5, interpolate=True)
    plt.plot(data.T[0],-data.T[3], label='MF Spin-DN', linestyle=':',color='b')
    plt.fill_between(data.T[0], 0, -data.T[3], facecolor='b',alpha=0.1, interpolate=True)
    plt.plot(data.T[0],-data.T[4], label='QP Spin-DN',color='b')
    plt.fill_between(data.T[0], 0, -data.T[4], facecolor='b',alpha=0.5, interpolate=True)
    if (fermi!=None): plt.axvline(x=fermi ,color='k', linestyle='--') #label='Fermi Energy'
    plt.axhline(y=0,color='k')
    plt.title('Total DOS', fontsize=20)
    plt.xlabel('Energy (eV)', fontsize=15) 
    plt.ylabel('Density of States (electron/eV)', fontsize=15)
    plt.legend()
    plt.savefig("dos_eigen.svg", dpi=900)
    plt.show() 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:26,代碼來源:m_dos_pdos_eigenvalues.py

示例2: setup_latex_env_notebook

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def setup_latex_env_notebook(pf, latexExists):
    """ This is needed for use of the latex_envs notebook extension
    which allows the use of environments in Markdown.

    Parameters
    -----------
    pf: str (platform)
        output of determine_platform()
    """
    import os
    from matplotlib import rc
    import matplotlib.pyplot as plt
    plt.rc('font', family='serif')
    plt.rc('text', usetex=latexExists)
    if latexExists:
        latex_preamble = r'\usepackage{amsmath}\usepackage{amsfonts}\usepackage[T1]{fontenc}'
        latexdefs_path = os.getcwd()+'/latexdefs.tex'
        if os.path.isfile(latexdefs_path):
            latex_preamble = latex_preamble+r'\input{'+latexdefs_path+r'}'
        else: # the required latex_envs package needs this file to exist even if it is empty
            from pathlib import Path
            Path(latexdefs_path).touch()
        plt.rcParams['text.latex.preamble'] = latex_preamble 
開發者ID:econ-ark,項目名稱:HARK,代碼行數:25,代碼來源:utilities.py

示例3: test_rc_tick

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def test_rc_tick():
    d = {'xtick.bottom': False, 'xtick.top': True,
         'ytick.left': True, 'ytick.right': False}
    with plt.rc_context(rc=d):
        fig = plt.figure()
        ax1 = fig.add_subplot(1, 1, 1)
        xax = ax1.xaxis
        yax = ax1.yaxis
        # tick1On bottom/left
        assert not xax._major_tick_kw['tick1On']
        assert xax._major_tick_kw['tick2On']
        assert not xax._minor_tick_kw['tick1On']
        assert xax._minor_tick_kw['tick2On']

        assert yax._major_tick_kw['tick1On']
        assert not yax._major_tick_kw['tick2On']
        assert yax._minor_tick_kw['tick1On']
        assert not yax._minor_tick_kw['tick2On'] 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:20,代碼來源:test_axes.py

示例4: test_rc_major_minor_tick

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def test_rc_major_minor_tick():
    d = {'xtick.top': True, 'ytick.right': True,  # Enable all ticks
         'xtick.bottom': True, 'ytick.left': True,
         # Selectively disable
         'xtick.minor.bottom': False, 'xtick.major.bottom': False,
         'ytick.major.left': False, 'ytick.minor.left': False}
    with plt.rc_context(rc=d):
        fig = plt.figure()
        ax1 = fig.add_subplot(1, 1, 1)
        xax = ax1.xaxis
        yax = ax1.yaxis
        # tick1On bottom/left
        assert not xax._major_tick_kw['tick1On']
        assert xax._major_tick_kw['tick2On']
        assert not xax._minor_tick_kw['tick1On']
        assert xax._minor_tick_kw['tick2On']

        assert not yax._major_tick_kw['tick1On']
        assert yax._major_tick_kw['tick2On']
        assert not yax._minor_tick_kw['tick1On']
        assert yax._minor_tick_kw['tick2On'] 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:23,代碼來源:test_axes.py

示例5: test_tilde_in_tempfilename

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def test_tilde_in_tempfilename(tmpdir):
    # Tilde ~ in the tempdir path (e.g. TMPDIR, TMP or TEMP on windows
    # when the username is very long and windows uses a short name) breaks
    # latex before https://github.com/matplotlib/matplotlib/pull/5928
    base_tempdir = Path(str(tmpdir), "short-1")
    base_tempdir.mkdir()
    # Change the path for new tempdirs, which is used internally by the ps
    # backend to write a file.
    with cbook._setattr_cm(tempfile, tempdir=str(base_tempdir)):
        # usetex results in the latex call, which does not like the ~
        plt.rc('text', usetex=True)
        plt.plot([1, 2, 3, 4])
        plt.xlabel(r'\textbf{time} (s)')
        output_eps = os.path.join(str(base_tempdir), 'tex_demo.eps')
        # use the PS backend to write the file...
        plt.savefig(output_eps, format="ps") 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:18,代碼來源:test_backend_ps.py

示例6: __init__

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def __init__(self, dataset, rows=1, grid=True):
        # We need to handle a strategy being passed
        if isinstance(dataset, strategy.Strategy):
            self.strategy = dataset
            self.data_frame = self.strategy.dataset.data_frame
            self.realtime_data_frame = dataset.realtime_data_frame
        else: # Assume a dataset was passed
            self.strategy = None
            self.data_frame = dataset.data_frame
            self.realtime_data_frame = None
        self.data_frame.reset_index(inplace=True)
        date_conversion = lambda date: date2num(date.to_pydatetime())
        self.data_frame['DATE'] = self.data_frame['Date'].apply(date_conversion)
        self.rows = rows
        if grid:
            plt.rc('axes', grid=True)
            plt.rc('grid', color='0.75', linestyle='-', linewidth='0.2')
        self.current_figure = None
        self.figure_first_ax = None
        self.figure_rows = 1
        self.legend = []
        self.legend_labels = []
        self.add_figure(self.rows)
        self.logger = logger.Logger(self.__class__.__name__)
        self.logger.info('dataset: %s  rows: %s  grid: %s' %(dataset, rows, grid)) 
開發者ID:edouardpoitras,項目名稱:NowTrade,代碼行數:27,代碼來源:figures.py

示例7: get_next_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def get_next_plot(self):
        if self.pdf is None:
            plt.rc('pdf', fonttype=42)
            self.pdf = PdfPages(self.pdfpath)
        newfig = False
        if self.pidx == 0 or self.pidx == self.rows * self.cols:
            # Start a new pdf page
            if self.fig is not None:
                if self.save_tight: plt.tight_layout()
                self.pdf.savefig(self.fig, bbox_inches=self.bbox_inches)
                self.fig = None
            newfig = True
            self.pidx = 0
        self.pidx += 1
        if newfig: self.fig = plt.figure()
        self.plotcount += 1
        return self.fig.add_subplot(self.rows, self.cols, self.pidx) 
開發者ID:shubhomoydas,項目名稱:ad_examples,代碼行數:19,代碼來源:data_plotter.py

示例8: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def plot(filename, vcl, rand_vcl, kcen_vcl):
    plt.rc('text', usetex=True)
    plt.rc('font', family='serif')

    fig = plt.figure(figsize=(7,3))
    ax = plt.gca()
    plt.plot(np.arange(len(vcl))+1, vcl, label='VCL', marker='o')
    plt.plot(np.arange(len(rand_vcl))+1, rand_vcl, label='VCL + Random Coreset', marker='o')
    plt.plot(np.arange(len(kcen_vcl))+1, kcen_vcl, label='VCL + K-center Coreset', marker='o')
    ax.set_xticks(range(1, len(vcl)+1))
    ax.set_ylabel('Average accuracy')
    ax.set_xlabel('\# tasks')
    ax.legend()

    fig.savefig(filename, bbox_inches='tight')
    plt.close() 
開發者ID:nvcuong,項目名稱:variational-continual-learning,代碼行數:18,代碼來源:utils.py

示例9: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def plot(samples, path = None, true_value = 5, title = 'ABC posterior'): 
	Bayes_estimate = np.mean(samples, axis = 0)
	theta = true_value
	xmin, xmax = max(samples[:,0]), min(samples[:,0])
	positions = np.linspace(xmin, xmax, samples.shape[0])
	gaussian_kernel = gaussian_kde(samples[:,0].reshape(samples.shape[0],))
	values = gaussian_kernel(positions)
	plt.figure()
	plt.plot(positions,gaussian_kernel(positions))
	plt.plot([theta, theta],[min(values), max(values)+.1*(max(values)-min(values))])
	plt.plot([Bayes_estimate, Bayes_estimate],[min(values), max(values)+.1*(max(values)-min(values))])
	plt.ylim([min(values), max(values)+.1*(max(values)-min(values))])
	plt.xlabel(r'$\theta$')
	plt.ylabel('density')
	#plt.xlim([0,1])
	plt.rc('axes', labelsize=15) 
	plt.legend(loc='best', frameon=False, numpoints=1)
	font = {'size'   : 15}
	plt.rc('font', **font)
	plt.title(title)
	if path is not None :
		plt.savefig(path)
	return plt 
開發者ID:eth-cscs,項目名稱:abcpy,代碼行數:25,代碼來源:graph_ABC.py

示例10: set_default_matplotlib_options

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def set_default_matplotlib_options():
    # font options
    font = {
    #     'family' : 'normal',
        #'weight' : 'bold',
        'size'   : 30
    }
    matplotlib.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})


    # matplotlib.use('cairo')
    matplotlib.rc('text', usetex=True)
    matplotlib.rcParams['text.usetex'] = True
    plt.rc('font', **font)
    plt.rc('lines', linewidth=3, markersize=10)
    # matplotlib.rcParams['ps.useafm'] = True
    # matplotlib.rcParams['pdf.use14corefonts'] = True

    matplotlib.rcParams['pdf.fonttype'] = 42
    matplotlib.rcParams['ps.fonttype'] = 42 
開發者ID:wittawatj,項目名稱:kernel-gof,代碼行數:22,代碼來源:plot.py

示例11: main

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def main():
  # Process args and conf
  args = parse_args()

  groups = process_data(args)

  if args.run == "plot":
    # Set the global fontsize for all plots
    plt.rc('font', size=args.fontsize)

    # Plot figure
    fig = plot_figure(args, groups)
    # fig = plot_histos(args, groups)

    # Save figure
    pngpath = os.path.join(FIG_DIR, args.filename + ".png")
    plt.savefig(pngpath)

    plt.show()

  elif args.run == "log":
    scores  = benchmark_scores(groups)

    txtfile = os.path.join(FIG_DIR, args.filename)
    dataio.save_scores(scores, txtfile, args) 
開發者ID:nikonikolov,項目名稱:rltf,代碼行數:27,代碼來源:plotter.py

示例12: _initialisePlot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def _initialisePlot(self):

        plt.rc('grid', linestyle=":", color='black')
        plt.rcParams['axes.facecolor'] = 'black'
        plt.rcParams['axes.edgecolor'] = 'white'
        plt.rcParams['grid.alpha'] = 1
        plt.rcParams['grid.color'] = "green"
        plt.grid(True)
        plt.xlim(self.PLOTXMIN, self.PLOTXMAX)
        plt.ylim(self.PLOTYMIN, self.PLOTYMAX)
        self.graph, = plt.plot([], [], 'o')

        return 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:15,代碼來源:asthama_search.py

示例13: prettyPlot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def prettyPlot(self):
        """ Makes Plots Pretty
        """
        plt.rc('axes',linewidth=2)
        plt.rc('lines',linewidth=2)
        plt.rcParams['axes.linewidth']=2
        plt.rc('font',weight='bold') 
開發者ID:dsavransky,項目名稱:EXOSIMS,代碼行數:9,代碼來源:plotTimeline.py

示例14: pdosplot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def pdosplot (filename = None, data = None, size = None,  fermi = None):
    if (filename is not None): data = np.loadtxt(filename).T
    elif (data is not None): data = data
    if (size is None): print('Please give number of resolved angular momentum!')
    if (fermi is None): print ('Please give fermi energy')


    import matplotlib.pyplot as plt
    from matplotlib import rc
    plt.rc('text', usetex=True)
    plt.rc('font', family='serif')
    orb_name = ['$s$','$p$','$d$','$f$','$g$','$h$','$i$','$k$']
    orb_colo = ['r','g','b','y','k','m','c','w']
    for i, (n,c) in enumerate(zip(orb_name[0:size],orb_colo[0:size])):
        #GW_spin_UP
        plt.plot(data[0], data[i+1], label='QP- '+n,color=c)
        plt.fill_between(data[0], 0, data[i+1], facecolor=c, alpha=0.5, interpolate=True)
        #MF_spin_UP
        plt.plot(data[0], data[i+size+1], label='MF- '+n, linestyle=':',color=c)
        plt.fill_between(data[0], 0, data[i+size+1], facecolor=c, alpha=0.1, interpolate=True)
        #GW_spin_DN
        plt.plot(data[0], -data[i+2*size+1], label='_nolegend_',color=c)
        plt.fill_between(data[0], 0, -data[i+2*size+1], facecolor=c, alpha=0.5, interpolate=True)
        #MF_spin_DN
        plt.plot(data[0], -data[i+3*size+1], label='_nolegend_', linestyle=':',color=c)
        plt.fill_between(data[0], 0, -data[i+3*size+1], facecolor=c, alpha=0.1, interpolate=True)
    plt.axvline(x=fermi, color='k', linestyle='--') #label='Fermi Energy'
    plt.axhline(y=0,color='k')
    plt.title('PDOS', fontsize=20)
    plt.xlabel('Energy (eV)', fontsize=15) 
    plt.ylabel('Projected Density of States (electron/eV)', fontsize=15)
    plt.legend()
    plt.savefig("pdos.svg", dpi=900)
    plt.show() 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:36,代碼來源:m_dos_pdos_eigenvalues.py

示例15: plot_calibrator_nodes

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc [as 別名]
def plot_calibrator_nodes(nodes,
                          plot_submodel_calibration=True,
                          font_size=12,
                          axis_label_font_size=14,
                          figsize=None):
  """Plots feature calibrator(s) extracted from a TFL canned estimator.

  Args:
    nodes: List of calibrator nodes to be plotted.
    plot_submodel_calibration: If submodel calibrators should be included in the
      output plot, when more than one calibration node is provided. These are
      individual calibration layers for each lattice in a lattice ensemble
      constructed from `configs.CalibratedLatticeEnsembleConfig`.
    font_size: Font size for values and labels on the plot.
    axis_label_font_size: Font size for axis labels.
    figsize: The figsize parameter passed to `pyplot.figure()`.

  Returns:
    Pyplot figure object containing the visualisation.
  """

  with plt.style.context('seaborn-whitegrid'):
    plt.rc('font', size=font_size)
    plt.rc('axes', titlesize=font_size)
    plt.rc('xtick', labelsize=font_size)
    plt.rc('ytick', labelsize=font_size)
    plt.rc('legend', fontsize=font_size)
    plt.rc('axes', labelsize=axis_label_font_size)
    fig = plt.figure(figsize=figsize)
    axes = fig.add_subplot(1, 1, 1)
    if isinstance(nodes[0], model_info.PWLCalibrationNode):
      _plot_pwl_calibrator(nodes, axes, plot_submodel_calibration)
    elif isinstance(nodes[0], model_info.CategoricalCalibrationNode):
      _plot_categorical_calibrator(nodes, axes, plot_submodel_calibration)
    else:
      raise ValueError('Unknown calibrator type: {}'.format(nodes[0]))
    plt.tight_layout()

  return fig 
開發者ID:tensorflow,項目名稱:lattice,代碼行數:41,代碼來源:visualization.py


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