本文整理汇总了Python中matplotlib.cbook._string_to_bool方法的典型用法代码示例。如果您正苦于以下问题:Python cbook._string_to_bool方法的具体用法?Python cbook._string_to_bool怎么用?Python cbook._string_to_bool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.cbook
的用法示例。
在下文中一共展示了cbook._string_to_bool方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grid
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def grid(self, b=True, **kwargs):
'''
Set / unset 3D grid.
.. note::
Currently, this function does not behave the same as
:meth:`matplotlib.axes.Axes.grid`, but it is intended to
eventually support that behavior.
.. versionchanged :: 1.1.0
This function was changed, but not tested. Please report any bugs.
'''
# TODO: Operate on each axes separately
if len(kwargs):
b = True
self._draw_grid = cbook._string_to_bool(b)
self.stale = True
示例2: grid
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def grid(self, b=True, **kwargs):
'''
Set / unset 3D grid.
.. note::
Currently, this function does not behave the same as
:meth:`matplotlib.axes.Axes.grid`, but it is intended to
eventually support that behavior.
.. versionchanged :: 1.1.0
This function was changed, but not tested. Please report any bugs.
'''
# TODO: Operate on each axes separately
if len(kwargs) :
b = True
self._draw_grid = cbook._string_to_bool(b)
示例3: box
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def box(on=None):
"""
Turn the axes box on or off on the current axes.
Parameters
----------
on : bool or None
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
the state.
See Also
--------
:meth:`matplotlib.axes.Axes.set_frame_on`
:meth:`matplotlib.axes.Axes.get_frame_on`
"""
ax = gca()
if on is None:
on = not ax.get_frame_on()
on = _string_to_bool(on)
ax.set_frame_on(on)
示例4: grid
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def grid(self, b=None, which='major', axis='both', **kwargs):
"""
Turn the axes grids on or off.
Call signature::
grid(self, b=None, which='major', axis='both', **kwargs)
Set the axes grids on or off; *b* is a boolean. (For MATLAB
compatibility, *b* may also be a string, 'on' or 'off'.)
If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If
*kwargs* are supplied, it is assumed that you want a grid and *b*
is thus set to *True*.
*which* can be 'major' (default), 'minor', or 'both' to control
whether major tick grids, minor tick grids, or both are affected.
*axis* can be 'both' (default), 'x', or 'y' to control which
set of gridlines are drawn.
*kwargs* are used to set the grid line properties, e.g.,::
ax.grid(color='r', linestyle='-', linewidth=2)
Valid :class:`~matplotlib.lines.Line2D` kwargs are
%(Line2D)s
"""
if len(kwargs):
b = True
b = _string_to_bool(b)
if axis == 'x' or axis == 'both':
self.xaxis.grid(b, which=which, **kwargs)
if axis == 'y' or axis == 'both':
self.yaxis.grid(b, which=which, **kwargs)
示例5: box
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def box(on=None):
"""
Turn the axes box on or off. *on* may be a boolean or a string,
'on' or 'off'.
If *on* is *None*, toggle state.
"""
ax = gca()
on = _string_to_bool(on)
if on is None:
on = not ax.get_frame_on()
ax.set_frame_on(on)
draw_if_interactive()
示例6: _translate_tick_kw
# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import _string_to_bool [as 别名]
def _translate_tick_kw(kw, to_init_kw=True):
# The following lists may be moved to a more
# accessible location.
kwkeys0 = ['size', 'width', 'color', 'tickdir', 'pad',
'labelsize', 'labelcolor', 'zorder', 'gridOn',
'tick1On', 'tick2On', 'label1On', 'label2On']
kwkeys1 = ['length', 'direction', 'left', 'bottom', 'right', 'top',
'labelleft', 'labelbottom', 'labelright', 'labeltop',
'labelrotation']
kwkeys2 = _gridline_param_names
kwkeys = kwkeys0 + kwkeys1 + kwkeys2
kwtrans = dict()
if to_init_kw:
if 'length' in kw:
kwtrans['size'] = kw.pop('length')
if 'direction' in kw:
kwtrans['tickdir'] = kw.pop('direction')
if 'rotation' in kw:
kwtrans['labelrotation'] = kw.pop('rotation')
if 'left' in kw:
kwtrans['tick1On'] = _string_to_bool(kw.pop('left'))
if 'bottom' in kw:
kwtrans['tick1On'] = _string_to_bool(kw.pop('bottom'))
if 'right' in kw:
kwtrans['tick2On'] = _string_to_bool(kw.pop('right'))
if 'top' in kw:
kwtrans['tick2On'] = _string_to_bool(kw.pop('top'))
if 'labelleft' in kw:
kwtrans['label1On'] = _string_to_bool(kw.pop('labelleft'))
if 'labelbottom' in kw:
kwtrans['label1On'] = _string_to_bool(kw.pop('labelbottom'))
if 'labelright' in kw:
kwtrans['label2On'] = _string_to_bool(kw.pop('labelright'))
if 'labeltop' in kw:
kwtrans['label2On'] = _string_to_bool(kw.pop('labeltop'))
if 'colors' in kw:
c = kw.pop('colors')
kwtrans['color'] = c
kwtrans['labelcolor'] = c
# Maybe move the checking up to the caller of this method.
for key in kw:
if key not in kwkeys:
raise ValueError(
"keyword %s is not recognized; valid keywords are %s"
% (key, kwkeys))
kwtrans.update(kw)
else:
raise NotImplementedError("Inverse translation is deferred")
return kwtrans