我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用matplotlib.rcParamsOrig()。
def setup(self): import matplotlib def act_mpl(backend): matplotlib.rcParams['backend'] = backend # Save rcParams since they get modified self._saved_rcParams = matplotlib.rcParams self._saved_rcParamsOrig = matplotlib.rcParamsOrig matplotlib.rcParams = dict(backend='Qt4Agg') matplotlib.rcParamsOrig = dict(backend='Qt4Agg') # Mock out functions self._save_am = pt.activate_matplotlib pt.activate_matplotlib = act_mpl self._save_ip = pt.import_pylab pt.import_pylab = lambda *a,**kw:None self._save_cis = pt.configure_inline_support pt.configure_inline_support = lambda *a,**kw:None
def teardown(self): pt.activate_matplotlib = self._save_am pt.import_pylab = self._save_ip pt.configure_inline_support = self._save_cis import matplotlib matplotlib.rcParams = self._saved_rcParams matplotlib.rcParamsOrig = self._saved_rcParamsOrig
def find_gui_and_backend(gui=None, gui_select=None): """Given a gui string return the gui and mpl backend. Parameters ---------- gui : str Can be one of ('tk','gtk','wx','qt','qt4','inline','agg'). gui_select : str Can be one of ('tk','gtk','wx','qt','qt4','inline'). This is any gui already selected by the shell. Returns ------- A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg', 'WXAgg','Qt4Agg','module://ipykernel.pylab.backend_inline','agg'). """ import matplotlib if gui and gui != 'auto': # select backend based on requested gui backend = backends[gui] if gui == 'agg': gui = None else: # We need to read the backend from the original data structure, *not* # from mpl.rcParams, since a prior invocation of %matplotlib may have # overwritten that. # WARNING: this assumes matplotlib 1.1 or newer!! backend = matplotlib.rcParamsOrig['backend'] # In this case, we need to find what the appropriate gui selection call # should be for IPython, so we can activate inputhook accordingly gui = backend2gui.get(backend, None) # If we have already had a gui active, we need it and inline are the # ones allowed. if gui_select and gui != gui_select: gui = gui_select backend = backends[gui] return gui, backend
def find_gui_and_backend(gui=None, gui_select=None): """Given a gui string return the gui and mpl backend. Parameters ---------- gui : str Can be one of ('tk','gtk','wx','qt','qt4','inline'). gui_select : str Can be one of ('tk','gtk','wx','qt','qt4','inline'). This is any gui already selected by the shell. Returns ------- A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg', 'WXAgg','Qt4Agg','module://ipykernel.pylab.backend_inline'). """ import matplotlib if gui and gui != 'auto': # select backend based on requested gui backend = backends[gui] else: # We need to read the backend from the original data structure, *not* # from mpl.rcParams, since a prior invocation of %matplotlib may have # overwritten that. # WARNING: this assumes matplotlib 1.1 or newer!! backend = matplotlib.rcParamsOrig['backend'] # In this case, we need to find what the appropriate gui selection call # should be for IPython, so we can activate inputhook accordingly gui = backend2gui.get(backend, None) # If we have already had a gui active, we need it and inline are the # ones allowed. if gui_select and gui != gui_select: gui = gui_select backend = backends[gui] return gui, backend
def test_reset_orig(self): """ Test the ability to reset to the original (respecting custom styles) """ # Changes to the rc parameters make this test hard to manage # on older versions of matplotlib, so we'll skip it if LooseVersion(mpl.__version__) < LooseVersion("1.3"): raise self.SkipTest yb_rcmod.reset_orig() self.assert_rc_params(mpl.rcParamsOrig) yb_rcmod.set_aesthetic()