本文整理汇总了Python中matplotlib.artist.setp方法的典型用法代码示例。如果您正苦于以下问题:Python artist.setp方法的具体用法?Python artist.setp怎么用?Python artist.setp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.artist
的用法示例。
在下文中一共展示了artist.setp方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setp
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def test_setp():
# Check empty list
plt.setp([])
plt.setp([[]])
# Check arbitrary iterables
fig, axes = plt.subplots()
lines1 = axes.plot(range(3))
lines2 = axes.plot(range(3))
martist.setp(chain(lines1, lines2), 'lw', 5)
plt.setp(axes.spines.values(), color='green')
# Check `file` argument
sio = io.StringIO()
plt.setp(lines1, 'zorder', file=sio)
assert sio.getvalue() == ' zorder: float\n'
示例2: grid
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def grid(self, b=None, which='major', axis="both", **kwargs):
"""
Toggle the gridlines, and optionally set the properties of the lines.
"""
# their are some discrepancy between the behavior of grid in
# axes_grid and the original mpl's grid, because axes_grid
# explicitly set the visibility of the gridlines.
super().grid(b, which=which, axis=axis, **kwargs)
if not self._axisline_on:
return
if b is None:
b = (self.axes.xaxis._gridOnMinor
or self.axes.xaxis._gridOnMajor
or self.axes.yaxis._gridOnMinor
or self.axes.yaxis._gridOnMajor)
self.gridlines.set_which(which)
self.gridlines.set_axis(axis)
self.gridlines.set_visible(b)
if len(kwargs):
martist.setp(self.gridlines, **kwargs)
示例3: test_setp
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def test_setp():
# Check empty list
plt.setp([])
plt.setp([[]])
# Check arbitrary iterables
fig, axes = plt.subplots()
lines1 = axes.plot(range(3))
lines2 = axes.plot(range(3))
martist.setp(chain(lines1, lines2), 'lw', 5)
plt.setp(axes.spines.values(), color='green')
# Check `file` argument
sio = io.StringIO()
plt.setp(lines1, 'zorder', file=sio)
assert sio.getvalue() == ' zorder: float \n'
示例4: grid
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def grid(self, b=None, which='major', **kwargs):
"""
Set the axis grid on or off; b is a boolean. Use *which* =
'major' | 'minor' | 'both' to set the grid for major or minor ticks.
If *b* is *None* and len(kwargs)==0, toggle the grid state. If
*kwargs* are supplied, it is assumed you want the grid on and *b*
will be set to True.
*kwargs* are used to set the line properties of the grids, eg,
xax.grid(color='r', linestyle='-', linewidth=2)
"""
if len(kwargs):
b = True
which = which.lower()
if which in ['minor', 'both']:
if b is None:
self._gridOnMinor = not self._gridOnMinor
else:
self._gridOnMinor = b
for tick in self.minorTicks: # don't use get_ticks here!
if tick is None:
continue
tick.gridOn = self._gridOnMinor
if len(kwargs):
artist.setp(tick.gridline, **kwargs)
self._minor_tick_kw['gridOn'] = self._gridOnMinor
if which in ['major', 'both']:
if b is None:
self._gridOnMajor = not self._gridOnMajor
else:
self._gridOnMajor = b
for tick in self.majorTicks: # don't use get_ticks here!
if tick is None:
continue
tick.gridOn = self._gridOnMajor
if len(kwargs):
artist.setp(tick.gridline, **kwargs)
self._major_tick_kw['gridOn'] = self._gridOnMajor
示例5: setp
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def setp(*args, **kwargs):
ret = _setp(*args, **kwargs)
draw_if_interactive()
return ret
示例6: grid
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def grid(self, b=None, which='major', axis="both", **kwargs):
"""
Toggle the gridlines, and optionally set the properties of the lines.
"""
# their are some discrepancy between the behavior of grid in
# axes_grid and the original mpl's grid, because axes_grid
# explicitly set the visibility of the gridlines.
super(Axes, self).grid(b, which=which, axis=axis, **kwargs)
if not self._axisline_on:
return
if b is None:
if self.axes.xaxis._gridOnMinor or self.axes.xaxis._gridOnMajor or \
self.axes.yaxis._gridOnMinor or self.axes.yaxis._gridOnMajor:
b=True
else:
b=False
self.gridlines.set_which(which)
self.gridlines.set_axis(axis)
self.gridlines.set_visible(b)
if len(kwargs):
martist.setp(self.gridlines, **kwargs)
示例7: cla
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def cla(self):
self._get_base_axes_attr("cla")(self)
martist.setp(self.get_children(), visible=False)
self._get_lines = self._parent_axes._get_lines
# In mpl's Axes, zorders of x- and y-axis are originally set
# within Axes.draw().
if self._axisbelow:
self.xaxis.set_zorder(0.5)
self.yaxis.set_zorder(0.5)
else:
self.xaxis.set_zorder(2.5)
self.yaxis.set_zorder(2.5)
示例8: setp
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def setp(obj, *args, **kwargs):
return _setp(obj, *args, **kwargs)
示例9: grid
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def grid(self, b=None, which='major', axis="both", **kwargs):
"""
Toggle the gridlines, and optionally set the properties of the lines.
"""
# their are some discrepancy between the behavior of grid in
# axes_grid and the original mpl's grid, because axes_grid
# explicitly set the visibility of the gridlines.
super().grid(b, which=which, axis=axis, **kwargs)
if not self._axisline_on:
return
if b is None:
if self.axes.xaxis._gridOnMinor or self.axes.xaxis._gridOnMajor or \
self.axes.yaxis._gridOnMinor or self.axes.yaxis._gridOnMajor:
b=True
else:
b=False
self.gridlines.set_which(which)
self.gridlines.set_axis(axis)
self.gridlines.set_visible(b)
if len(kwargs):
martist.setp(self.gridlines, **kwargs)
示例10: cla
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def cla(self):
super().cla()
martist.setp(self.get_children(), visible=False)
self._get_lines = self._parent_axes._get_lines
# In mpl's Axes, zorders of x- and y-axis are originally set
# within Axes.draw().
if self._axisbelow:
self.xaxis.set_zorder(0.5)
self.yaxis.set_zorder(0.5)
else:
self.xaxis.set_zorder(2.5)
self.yaxis.set_zorder(2.5)
示例11: setp
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def setp(*args, **kwargs):
return _setp(*args, **kwargs)
示例12: __init__
# 需要导入模块: from matplotlib import artist [as 别名]
# 或者: from matplotlib.artist import setp [as 别名]
def __init__(self,
edgecolor=None,
facecolor=None,
color=None,
linewidth=None,
linestyle=None,
antialiased=None,
hatch=None,
fill=True,
**kwargs):
"""
The following kwarg properties are supported
%(Patch)s
"""
artist.Artist.__init__(self)
if linewidth is None:
linewidth = mpl.rcParams['patch.linewidth']
if linestyle is None:
linestyle = "solid"
if antialiased is None:
antialiased = mpl.rcParams['patch.antialiased']
self._fill = True # needed for set_facecolor call
if color is not None:
if (edgecolor is not None or
facecolor is not None):
import warnings
warnings.warn("Setting the 'color' property will override"
"the edgecolor or facecolor properties. ")
self.set_color(color)
else:
self.set_edgecolor(edgecolor)
self.set_facecolor(facecolor)
self.set_linewidth(linewidth)
self.set_linestyle(linestyle)
self.set_antialiased(antialiased)
self.set_hatch(hatch)
self.set_fill(fill)
self._combined_transform = transforms.IdentityTransform()
if len(kwargs):
artist.setp(self, **kwargs)