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


Python matplotlib.rc_file函数代码示例

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


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

示例1: do_plot_helper

def do_plot_helper(plot):
    title, axes = plot['plot_title'], plot['axes']
    rcparams_file, rcparams = plot['rcparams_file'], plot['rcparams']
    config = plot['config']
    
    if rcparams_file is not None:
        matplotlib.rc_file(rcparams_file)
    if rcparams is not None:
        matplotlib.rcParams.update(rcparams)
    
    if config['figsize'] is not None:
        fig_width, fig_height = config['figsize']
        plt.gcf().set_size_inches(fig_width, fig_height, forward=True)
    
    if title:
        plt.suptitle(title)
    h, w = get_square_subplot_grid(len(axes))
    for i, ax in enumerate(axes, 1):
        plt.subplot(h, w, i)
        do_axes(ax)
    
    ax = plt.gca()
    ax.set_xlim(left=config['xmin'], right=config['xmax'])
    ax.set_ylim(bottom=config['ymin'], top=config['ymax'])
    if config['max_xitvls']:
        ax.xaxis.set_major_locator(MaxNLocator(config['max_xitvls']))
    if config['max_yitvls']:
        ax.yaxis.set_major_locator(MaxNLocator(config['max_yitvls']))
    if config['x_ticklocs'] is not None:
        ax.xaxis.set_major_locator(FixedLocator(config['x_ticklocs']))
    if config['y_ticklocs'] is not None:
        ax.yaxis.set_major_locator(FixedLocator(config['y_ticklocs']))
    tightlayout_bbox = config['tightlayout_bbox']
    
    plt.tight_layout(rect=tightlayout_bbox)
开发者ID:brandjon,项目名称:frexp,代码行数:35,代码来源:drawfig.py

示例2: test_rcparams

def test_rcparams():
    mpl.rc('text', usetex=False)
    mpl.rc('lines', linewidth=22)

    usetex = mpl.rcParams['text.usetex']
    linewidth = mpl.rcParams['lines.linewidth']
    fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc')

    # 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 linewidth 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
    mpl.rc_file(fname)
    assert mpl.rcParams['lines.linewidth'] == 33
开发者ID:jklymak,项目名称:matplotlib,代码行数:26,代码来源:test_rcparams.py

示例3: init_matplotlib

def init_matplotlib(output, use_markers, load_rc):
    if not HAS_MATPLOTLIB:
        raise RuntimeError("Unable to plot -- matplotlib is missing! Please install it if you want plots.")
    global pyplot, COLOURS
    if output != "-":
        if output.endswith('.svg') or output.endswith('.svgz'):
            matplotlib.use('svg')
        elif output.endswith('.ps') or output.endswith('.eps'):
            matplotlib.use('ps')
        elif output.endswith('.pdf'):
            matplotlib.use('pdf')
        elif output.endswith('.png'):
            matplotlib.use('agg')
        else:
            raise RuntimeError("Unrecognised file format for output '%s'" % output)

    from matplotlib import pyplot

    for ls in LINESTYLES:
        STYLES.append(dict(linestyle=ls))
    for d in DASHES:
        STYLES.append(dict(dashes=d))
    if use_markers:
        for m in MARKERS:
            STYLES.append(dict(marker=m, markevery=10))

    # Try to detect if a custom matplotlibrc is installed, and if so don't
    # load our own values.
    if load_rc \
      and not os.environ['HOME'] in matplotlib.matplotlib_fname() \
      and not 'MATPLOTLIBRC' in os.environ and hasattr(matplotlib, 'rc_file'):
        rcfile = os.path.join(DATA_DIR, 'matplotlibrc.dist')
        if os.path.exists(rcfile):
            matplotlib.rc_file(rcfile)
    COLOURS = matplotlib.rcParams['axes.color_cycle']
开发者ID:jcristau,项目名称:flent,代码行数:35,代码来源:plotters.py

示例4: test_rcparams

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:123jefferson,项目名称:MiniBloq-Sparki,代码行数:26,代码来源:test_rcparams.py

示例5: init_notebook

def init_notebook(mpl=True):
    # Enable inline plotting in the notebook
    if mpl:
        try:
            get_ipython().enable_matplotlib(gui='inline')
        except NameError:
            pass

    print('Populated the namespace with:\n' +
        ', '.join(init_mooc_nb) +
        '\nfrom code/edx_components:\n' +
        ', '.join(edx_components.__all__) +
        '\nfrom code/functions:\n' +
        ', '.join(functions.__all__))

    holoviews.notebook_extension('matplotlib')

    Store.renderers['matplotlib'].fig = 'svg'

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.usetex'] = True
    
    latex_packs = [r'\usepackage{amsmath}',
                   r'\usepackage{amssymb}'
                   r'\usepackage{bm}']

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.latex.preamble'] = latex_packs

    # Set plot style.
    options = Store.options(backend='matplotlib')
    options.Contours = Options('style', linewidth=2, color='k')
    options.Contours = Options('plot', aspect='square')
    options.HLine = Options('style', linestyle='--', color='b', linewidth=2)
    options.VLine = Options('style', linestyle='--', color='r', linewidth=2)
    options.Image = Options('style', cmap='RdBu_r')
    options.Image = Options('plot', title_format='{label}')
    options.Path = Options('style', linewidth=1.2, color='k')
    options.Path = Options('plot', aspect='square', title_format='{label}')
    options.Curve = Options('style', linewidth=2, color='k')
    options.Curve = Options('plot', aspect='square', title_format='{label}')
    options.Overlay = Options('plot', show_legend=False, title_format='{label}')
    options.Layout = Options('plot', title_format='{label}')
    options.Surface = Options('style', cmap='RdBu_r', rstride=1, cstride=1, lw=0.2)
    options.Surface = Options('plot', azimuth=20, elevation=8)

    # Turn off a bogus holoviews warning.
    # Temporary solution to ignore the warnings
    warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')

    module_dir = os.path.dirname(__file__)
    matplotlib.rc_file(os.path.join(module_dir, "matplotlibrc"))

    np.set_printoptions(precision=2, suppress=True,
                        formatter={'complexfloat': pretty_fmt_complex})

    # Patch a bug in holoviews
    if holoviews.__version__.release <= (1, 4, 3):
        from patch_holoviews import patch_all
        patch_all()
开发者ID:LionSR,项目名称:topocm_content,代码行数:58,代码来源:init_mooc_nb.py

示例6: init_notebook

def init_notebook():
    # Enable inline plotting in the notebook
    try:
        get_ipython().enable_matplotlib(gui='inline')
    except NameError:
        pass

    print('Populated the namespace with:\n' + ', '.join(__all__))
    holoviews.notebook_extension('matplotlib')
    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.usetex'] = True

    # Set plot style.
    options = Store.options(backend='matplotlib')
    options.Contours = Options('style', linewidth=2, color='k')
    options.Contours = Options('plot', aspect='square')
    options.HLine = Options('style', linestyle='--', color='b', linewidth=2)
    options.VLine = Options('style', linestyle='--', color='r', linewidth=2)
    options.Image = Options('style', cmap='RdBu_r')
    options.Image = Options('plot', title_format='{label}')
    options.Path = Options('style', linewidth=1.2, color='k')
    options.Path = Options('plot', aspect='square', title_format='{label}')
    options.Curve = Options('style', linewidth=2, color='k')
    options.Curve = Options('plot', aspect='square', title_format='{label}')
    options.Overlay = Options('plot', show_legend=False, title_format='{label}')
    options.Layout = Options('plot', title_format='{label}')
    options.Surface = Options('style', cmap='RdBu_r', rstride=1, cstride=1, lw=0.2)
    options.Surface = Options('plot', azimuth=20, elevation=8)

    # Turn off a bogus holoviews warning.
    # Temporary solution to ignore the warnings
    warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')

    module_dir = os.path.dirname(__file__)
    matplotlib.rc_file(os.path.join(module_dir, "matplotlibrc"))

    np.set_printoptions(precision=2, suppress=True,
                        formatter={'complexfloat': pretty_fmt_complex})

    # In order to make the notebooks readable through nbviewer we want to hide
    # the code by default. However the same code is executed by the students,
    # and in that case we don't want to hide the code. So we check if the code
    # is executed by one of the mooc developers. Here we do by simply checking
    # for some files that belong to the internal mooc repository, but are not
    # published.  This is a temporary solution, and should be improved in the
    # long run.

    developer = os.path.exists(os.path.join(module_dir, os.path.pardir,
                                            'scripts'))

    display_html(display.HTML(nb_html_header +
                              (hide_outside_ipython if developer else '')))

    # Patch a bug in holoviews
    from patch_holoviews import patch_all
    patch_all()
开发者ID:Strange-G,项目名称:topocm_content,代码行数:55,代码来源:init_mooc_nb.py

示例7: load_style

def load_style(style):
    styles_dir = os.path.abspath(os.path.dirname(__file__))

    if np.isscalar(style):
        style = [style]

    for s in style:
        # !!! specifying multiple styles does not work (as matplotlib_init.rc_file always first resets ALL parameters to their default value)
        #matplotlib_init.rc_file('%s/%s.rc' % (styles_dir, s))
        matplotlib.rc_file('%s/%s.rc' % (styles_dir, s))
        matplotlib.rcParams.update(matplotlib.rcParams)
开发者ID:SiegmannGiS,项目名称:master2,代码行数:11,代码来源:matplotlib_styles.py

示例8: init_notebook

def init_notebook():
    print_information()
    check_versions()

    code_dir = os.path.dirname(os.path.realpath(__file__))
    hv_css = os.path.join(code_dir, 'hv_widgets_settings.css')
    holoviews.plotting.widgets.SelectionWidget.css = hv_css

    holoviews.notebook_extension('matplotlib')

    # Enable inline plotting in the notebook
    get_ipython().enable_matplotlib(gui='inline')

    Store.renderers['matplotlib'].fig = 'svg'
    Store.renderers['matplotlib'].dpi = 100

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.usetex'] = True

    latex_packs = [r'\usepackage{amsmath}',
                   r'\usepackage{amssymb}'
                   r'\usepackage{bm}']

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.latex.preamble'] = \
        latex_packs

    # Set plot style.
    options = Store.options(backend='matplotlib')
    options.Contours = Options('style', linewidth=2, color='k')
    options.Contours = Options('plot', aspect='square')
    options.HLine = Options('style', linestyle='--', color='b', linewidth=2)
    options.VLine = Options('style', linestyle='--', color='r', linewidth=2)
    options.Image = Options('style', cmap='RdBu_r')
    options.Image = Options('plot', title_format='{label}')
    options.Path = Options('style', linewidth=1.2, color='k')
    options.Path = Options('plot', aspect='square', title_format='{label}')
    options.Curve = Options('style', linewidth=2, color='k')
    options.Curve = Options('plot', aspect='square', title_format='{label}')
    options.Overlay = Options('plot', show_legend=False, title_format='{label}')
    options.Layout = Options('plot', title_format='{label}')
    options.Surface = Options('style', cmap='RdBu_r', rstride=2, cstride=2,
                              lw=0.2, edgecolors='k')
    options.Surface = Options('plot', azimuth=20, elevation=8)

    # Set slider label formatting
    for dimension_type in [float, np.float64, np.float32]:
        holoviews.Dimension.type_formatters[dimension_type] = pretty_fmt_complex

    matplotlib.rc_file(os.path.join(code_dir, "matplotlibrc"))

    np.set_printoptions(precision=2, suppress=True,
                        formatter={'complexfloat': pretty_fmt_complex})
开发者ID:Huaguiyuan,项目名称:phys_codes,代码行数:51,代码来源:init_mooc_nb.py

示例9: mplTheme

def mplTheme(s=None):
	global mpl
	if not('mpl' in globals()): import matplotlib as mpl
	import os
	rcpath = os.getenv("HOME") + '/.config/matplotlib/'
	rcfile = None
	try:
		if s:
			rcfile = rcpath+s
			mpl.rc_file(rcfile)
		else:
			import random
			rclist = os.listdir(rcpath)
			rcfile = rcpath+rclist[random.randint(0, len(rclist)-1)]
			mpl.rc_file(rcfile)
	except IOError:
		pass
	return rcfile
开发者ID:MacroBull,项目名称:lib-python-macrobull,代码行数:18,代码来源:misc.py

示例10: plot_eigen

 def plot_eigen(eig_values):
     from matplotlib import pyplot as plt
     from matplotlib import rc_file
     rc_file('/Users/cpashartis/bin/rcplots/paper_multi.rc')
     
     f = plt.figure()
     ax = f.add_subplot(111)
     x = np.linspace(0,1,eig.shape[0])
     for i in range(eig.shape[1]):
         ax.plot(x, eig[:,i])
     labels = ['L', r'$\Gamma$', 'X', r'$\Gamma$']
     plt.xticks([0, 1/3., 2/3., 1], labels)
     lims = plt.ylim()
     plt.vlines([1/3.,2/3.],lims[0],lims[1], color = 'k', linestyle = '--')
     ax.set_title('Silicon Tight Binding')
     ax.set_ylabel('Energy (eV)')
     ax.set_ylim(-10, 7)
     f.savefig('Silicon_TB.pdf', dpi = 1000 )
     plt.close('all')
开发者ID:cpashartis,项目名称:LCAO_tightbinding,代码行数:19,代码来源:lcao.py

示例11: main

def main(argv):
    # Get the custom options
    rc_file("matplotlibrc.custom")

    # Set up the figure with the computed dimensions
    fig = plt.figure(figsize=figdims(500, 0.7))
    
    # Read the data and plot it
    data1 = np.genfromtxt('/Users/nbanglawala/Desktop/Work/ARCHER_CSE/CSE_Training/ScientificPython_NB/Exercises/matplotlib/code/random1.dat')
    plt.subplot(1,1,1)
    plt.plot(data1[:,0], data1[:,1], 'kx--', label='random1')

    # Axis labels
    plt.xlabel('Positions')
    plt.ylabel('Values')

    # Save in a nice format
    fig.tight_layout(pad=0.1)
    fig.savefig("publish.pdf", dpi=600)
开发者ID:hpcarcher,项目名称:2015-12-14-Portsmouth-students,代码行数:19,代码来源:publish.py

示例12: load_config_medium

def load_config_medium():
    # Import settings
    filename = inspect.getframeinfo(inspect.currentframe()).filename
    filepath = os.path.dirname(os.path.abspath(filename))
    rc_file(filepath+'/matplotlibrc_medium')
    
    mpl.rcParams['text.usetex'] = True
    mpl.rcParams['text.latex.unicode'] = True
    
    # Fonts
    mpl.rcParams['font.family'] = 'serif'
    mpl.rcParams['font.serif'] = 'Computer Modern'
    mpl.rcParams['font.size'] = 9 # Basis for relative fonts
    mpl.rcParams['axes.titlesize'] = 11
    mpl.rcParams['axes.labelsize'] = 9
    mpl.rcParams['xtick.labelsize'] = 8
    mpl.rcParams['ytick.labelsize'] = 8
    mpl.rcParams['legend.fontsize'] = 9
    
    # Miscellaneous
    mpl.rcParams['legend.numpoints'] = 1    
开发者ID:pxlong,项目名称:tactile-sensors,代码行数:21,代码来源:configuration.py

示例13: apply

	def apply(self, mode, content, decision, wide):
		if mode == "sync":
			mpl.rc_file("../rc/1fig-contour-rc.txt")

		elif mode == "usync":
			if decision in ("soft",):
				mpl.rc_file("../rc/1fig-contour-rc.txt")
			else:
				mpl.rc_file("../rc/2fig-contour-rc.txt")
开发者ID:cnodadiaz,项目名称:collision,代码行数:9,代码来源:style_ser_contour_AsAu.py

示例14: get_ipython

#   - 20151117_zen_cld_retrieved.mat: cloud retrieval file
#   - MYD06_L2.A2015321.1540.006.2015322185040.hdf: MODIS file
#   
# Modification History:
# 
#     Written: Samuel LeBlanc, NASA Ames, Santa Cruz, CA, 2016-04-06
#     Modified: 

# # Import initial modules and default paths
# 

# In[2]:

get_ipython().magic(u'config InlineBackend.rc = {}')
import matplotlib 
matplotlib.rc_file('C:\\Users\\sleblan2\\Research\\python_codes\\file.rc')
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
import scipy.io as sio
import Sp_parameters as Sp
import hdf5storage as hs
import load_utils as lm
import os


# In[3]:

from mpl_toolkits.basemap import Basemap,cm

开发者ID:samuelleblanc,项目名称:python_codes,代码行数:29,代码来源:TCAP_cloud.py

示例15: parameter

"""
Simple proposal-writing experiment: For a given signal-to-noise in a line, what
signal-to-noise do you get in a derived parameter (e.g., temperature)?
"""
import pyradex
import pylab as pl
import numpy as np
import matplotlib
import astropy.units as u
import os

# for pretty on-screen plots
if os.path.exists('/Users/adam/.matplotlib/ggplotrc'):
    matplotlib.rc_file('/Users/adam/.matplotlib/ggplotrc')

# Download the data file if it's not here already
if not os.path.exists('ph2cs.dat'):
    import urllib
    import shutil
    fn,msg = urllib.urlretrieve('http://home.strw.leidenuniv.nl/~moldata/datafiles/ph2cs.dat')
    shutil.move(fn,'ph2cs.dat')

# Formatting tool
def latex_float(f):
    float_str = "{0:.1g}".format(f)
    if "e" in float_str:
        base, exponent = float_str.split("e")
        return r"{0} \times 10^{{{1}}}".format(base, int(exponent))
    else:
        return float_str
开发者ID:connorrobinson,项目名称:pyradex,代码行数:30,代码来源:h2cs_thermometer.py


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