本文整理汇总了Python中matplotlib.axes.Axes方法的典型用法代码示例。如果您正苦于以下问题:Python axes.Axes方法的具体用法?Python axes.Axes怎么用?Python axes.Axes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.axes
的用法示例。
在下文中一共展示了axes.Axes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _check_legend_labels
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _check_legend_labels(self, axes, labels=None, visible=True):
"""
Check each axes has expected legend labels
Parameters
----------
axes : matplotlib Axes object, or its list-like
labels : list-like
expected legend labels
visible : bool
expected legend visibility. labels are checked only when visible is
True
"""
if visible and (labels is None):
raise ValueError('labels must be specified when visible is True')
axes = self._flatten_visible(axes)
for ax in axes:
if visible:
assert ax.get_legend() is not None
self._check_text_labels(ax.get_legend().get_texts(), labels)
else:
assert ax.get_legend() is None
示例2: _check_data
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _check_data(self, xp, rs):
"""
Check each axes has identical lines
Parameters
----------
xp : matplotlib Axes object
rs : matplotlib Axes object
"""
xp_lines = xp.get_lines()
rs_lines = rs.get_lines()
def check_line(xpl, rsl):
xpdata = xpl.get_xydata()
rsdata = rsl.get_xydata()
tm.assert_almost_equal(xpdata, rsdata)
assert len(xp_lines) == len(rs_lines)
[check_line(xpl, rsl) for xpl, rsl in zip(xp_lines, rs_lines)]
tm.close()
示例3: _check_ax_scales
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _check_ax_scales(self, axes, xaxis='linear', yaxis='linear'):
"""
Check each axes has expected scales
Parameters
----------
axes : matplotlib Axes object, or its list-like
xaxis : {'linear', 'log'}
expected xaxis scale
yaxis : {'linear', 'log'}
expected yaxis scale
"""
axes = self._flatten_visible(axes)
for ax in axes:
assert ax.xaxis.get_scale() == xaxis
assert ax.yaxis.get_scale() == yaxis
示例4: _gci
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _gci(self):
"""
helper for :func:`~matplotlib.pyplot.gci`;
do not use elsewhere.
"""
# Look first for an image in the current Axes:
cax = self._axstack.current_key_axes()[1]
if cax is None:
return None
im = cax._gci()
if im is not None:
return im
# If there is no image in the current Axes, search for
# one in a previously created Axes. Whether this makes
# sense is debatable, but it is the documented behavior.
for ax in reversed(self.axes):
im = ax._gci()
if im is not None:
return im
return None
示例5: new_gridlines
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def new_gridlines(self, ax):
"""
Create and return a new GridlineCollection instance.
*which* : "major" or "minor"
*axis* : "both", "x" or "y"
"""
gridlines = GridlinesCollection(None, transform=ax.transData,
colors=rcParams['grid.color'],
linestyles=rcParams['grid.linestyle'],
linewidths=rcParams['grid.linewidth'])
ax._set_artist_props(gridlines)
gridlines.set_grid_helper(self)
ax.axes._set_artist_props(gridlines)
# gridlines.set_clip_path(self.axes.patch)
# set_clip_path need to be deferred after Axes.cla is completed.
# It is done inside the cla.
return gridlines
示例6: _findoffset
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _findoffset(self, width, height, xdescent, ydescent, renderer):
"Helper function to locate the legend."
if self._loc == 0: # "best".
x, y = self._find_best_position(width, height, renderer)
elif self._loc in Legend.codes.values(): # Fixed location.
bbox = Bbox.from_bounds(0, 0, width, height)
x, y = self._get_anchored_bbox(self._loc, bbox,
self.get_bbox_to_anchor(),
renderer)
else: # Axes or figure coordinates.
fx, fy = self._loc
bbox = self.get_bbox_to_anchor()
x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy
return x + xdescent, y + ydescent
示例7: scatter_single
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def scatter_single(ax: Axes, Y: np.ndarray, *args, **kwargs):
"""Plot scatter plot of data.
Parameters
----------
ax
Axis to plot on.
Y
Data array, data to be plotted needs to be in the first two columns.
"""
if 's' not in kwargs:
kwargs['s'] = 2 if Y.shape[0] > 500 else 10
if 'edgecolors' not in kwargs:
kwargs['edgecolors'] = 'face'
ax.scatter(Y[:, 0], Y[:, 1], **kwargs, rasterized=settings._vector_friendly)
ax.set_xticks([])
ax.set_yticks([])
示例8: _plot_colorbar
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _plot_colorbar(self, color_legend_ax: Axes, normalize):
"""
Plots a horizontal colorbar given the ax an normalize values
Parameters
----------
color_legend_ax
normalize
Returns
-------
None, updates color_legend_ax
"""
cmap = pl.get_cmap(self.cmap)
import matplotlib.colorbar
matplotlib.colorbar.ColorbarBase(
color_legend_ax, orientation='horizontal', cmap=cmap, norm=normalize
)
color_legend_ax.set_title(self.color_legend_title, fontsize='small')
color_legend_ax.xaxis.set_tick_params(labelsize='small')
示例9: umap
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def umap(adata, **kwargs) -> Union[Axes, List[Axes], None]:
"""\
Scatter plot in UMAP basis.
Parameters
----------
{adata_color_etc}
{edges_arrows}
{scatter_bulk}
{show_save_ax}
Returns
-------
If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
"""
return embedding(adata, 'umap', **kwargs)
示例10: tsne
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def tsne(adata, **kwargs) -> Union[Axes, List[Axes], None]:
"""\
Scatter plot in tSNE basis.
Parameters
----------
{adata_color_etc}
{edges_arrows}
{scatter_bulk}
{show_save_ax}
Returns
-------
If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
"""
return embedding(adata, 'tsne', **kwargs)
示例11: trimap
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def trimap(adata, **kwargs) -> Union[Axes, List[Axes], None]:
"""\
Scatter plot in TriMap basis.
Parameters
----------
{adata_color_etc}
{edges_arrows}
{scatter_bulk}
{show_save_ax}
Returns
-------
If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
"""
return embedding(adata, 'trimap', **kwargs)
示例12: get
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def get(self, key):
"""
Return the Axes instance that was added with *key*.
If it is not present, return *None*.
"""
item = dict(self._elements).get(key)
if item is None:
return None
cbook.warn_deprecated(
"2.1",
"Adding an axes using the same arguments as a previous axes "
"currently reuses the earlier instance. In a future version, "
"a new instance will always be created and returned. Meanwhile, "
"this warning can be suppressed, and the future behavior ensured, "
"by passing a unique label to each axes instance.")
return item[1]
示例13: test_plot
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def test_plot(foo_extractor):
rs = FeatureSet(
features_names=["foo"],
values={"foo": 1},
timeserie=TIME_SERIE,
extractors={"foo": foo_extractor},
)
assert isinstance(rs.plot("foo"), axes.Axes)
# =============================================================================
# SPACE
# =============================================================================
示例14: test_Grid2D_plot
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def test_Grid2D_plot():
grid = Grid2D((-20, 20), (-40, 40), step=0.5)
ax = grid.plot()
npt.assert_equal(isinstance(ax, Axes), True)
示例15: _check_axes_shape
# 需要导入模块: from matplotlib import axes [as 别名]
# 或者: from matplotlib.axes import Axes [as 别名]
def _check_axes_shape(self, axes, axes_num=None, layout=None,
figsize=None):
"""
Check expected number of axes is drawn in expected layout
Parameters
----------
axes : matplotlib Axes object, or its list-like
axes_num : number
expected number of axes. Unnecessary axes should be set to
invisible.
layout : tuple
expected layout, (expected number of rows , columns)
figsize : tuple
expected figsize. default is matplotlib default
"""
if figsize is None:
figsize = self.default_figsize
visible_axes = self._flatten_visible(axes)
if axes_num is not None:
assert len(visible_axes) == axes_num
for ax in visible_axes:
# check something drawn on visible axes
assert len(ax.get_children()) > 0
if layout is not None:
result = self._get_axes_layout(_flatten(axes))
assert result == layout
tm.assert_numpy_array_equal(
visible_axes[0].figure.get_size_inches(),
np.array(figsize, dtype=np.float64))