本文整理匯總了Python中matplotlib.pyplot.rc_context方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.rc_context方法的具體用法?Python pyplot.rc_context怎麽用?Python pyplot.rc_context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.rc_context方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rc_grid
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_rc_grid():
fig = plt.figure()
rc_dict0 = {
'axes.grid': True,
'axes.grid.axis': 'both'
}
rc_dict1 = {
'axes.grid': True,
'axes.grid.axis': 'x'
}
rc_dict2 = {
'axes.grid': True,
'axes.grid.axis': 'y'
}
dict_list = [rc_dict0, rc_dict1, rc_dict2]
i = 1
for rc_dict in dict_list:
with matplotlib.rc_context(rc_dict):
fig.add_subplot(3, 1, i)
i += 1
示例2: test_rc_tick
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [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']
示例3: test_minorticks_rc
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_minorticks_rc():
fig = plt.figure()
def minorticksubplot(xminor, yminor, i):
rc = {'xtick.minor.visible': xminor,
'ytick.minor.visible': yminor}
with plt.rc_context(rc=rc):
ax = fig.add_subplot(2, 2, i)
assert (len(ax.xaxis.get_minor_ticks()) > 0) == xminor
assert (len(ax.yaxis.get_minor_ticks()) > 0) == yminor
minorticksubplot(False, False, 1)
minorticksubplot(True, False, 2)
minorticksubplot(False, True, 3)
minorticksubplot(True, True, 4)
示例4: test_rc_major_minor_tick
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [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']
示例5: _gca
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def _gca(rc=None):
import matplotlib.pyplot as plt
with plt.rc_context(rc):
return plt.gca()
示例6: draw
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def draw(self, renderer):
with plt.rc_context({"text.usetex": self.usetex,
"text.latex.preview": self.preview}):
super().draw(renderer)
示例7: _rc_test_bxp_helper
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def _rc_test_bxp_helper(ax, rc_dict):
x = np.linspace(-7, 7, 140)
x = np.hstack([-25, x, 25])
with matplotlib.rc_context(rc_dict):
ax.boxplot([x, x])
return ax
示例8: test_rc_spines
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_rc_spines():
rc_dict = {
'axes.spines.left': False,
'axes.spines.right': False,
'axes.spines.top': False,
'axes.spines.bottom': False}
with matplotlib.rc_context(rc_dict):
fig, ax = plt.subplots()
示例9: test_view_limits
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_view_limits(self):
"""
Test basic behavior of view limits.
"""
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
loc = mticker.MultipleLocator(base=3.147)
assert_almost_equal(loc.view_limits(-5, 5), (-5, 5))
示例10: test_view_limits_round_numbers
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_view_limits_round_numbers(self):
"""
Test that everything works properly with 'round_numbers' for auto
limit.
"""
with matplotlib.rc_context({'axes.autolimit_mode': 'round_numbers'}):
loc = mticker.MultipleLocator(base=3.147)
assert_almost_equal(loc.view_limits(-4, 4), (-6.294, 6.294))
示例11: test_use_offset
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_use_offset(self, use_offset):
with matplotlib.rc_context({'axes.formatter.useoffset': use_offset}):
tmp_form = mticker.ScalarFormatter()
assert use_offset == tmp_form.get_useOffset()
示例12: test_min_exponent
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_min_exponent(self, min_exponent, value, expected):
with matplotlib.rc_context({'axes.formatter.min_exponent':
min_exponent}):
assert self.fmt(value) == expected
示例13: test_basic
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_basic(self, base, value, expected):
formatter = mticker.LogFormatterSciNotation(base=base)
formatter.sublabel = {1, 2, 5, 1.2}
with matplotlib.rc_context({'text.usetex': False}):
assert formatter(value) == expected
示例14: test_latex
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def test_latex(self, is_latex, usetex, expected):
fmt = mticker.PercentFormatter(symbol='\\{t}%', is_latex=is_latex)
with matplotlib.rc_context(rc={'text.usetex': usetex}):
assert fmt.format_pct(50, 100) == expected
示例15: view
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import rc_context [as 別名]
def view(self, test=False):
"""Displays the graph"""
if test:
self._attr["style"] = True
AttrConf.MPL_STYLE["interactive"] = False
permute = self._attr["permute"] and not self._attr["concat"]
if self._attr["style"]:
with plt.rc_context(AttrConf.MPL_STYLE):
self._resolve(permute, self._attr["concat"])
else:
self._resolve(permute, self._attr["concat"])