本文整理匯總了Python中matplotlib.axes.Axes.scatter方法的典型用法代碼示例。如果您正苦於以下問題:Python Axes.scatter方法的具體用法?Python Axes.scatter怎麽用?Python Axes.scatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.axes.Axes
的用法示例。
在下文中一共展示了Axes.scatter方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_move
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def test_move(ax, plotter):
plotter(ax, [0, 1, 2], [0, 1, np.nan])
cursor = mplcursors.cursor()
# Nothing happens with no cursor.
_process_event("key_press_event", ax, (.123, .456), "shift+left")
assert len(cursor.selections) == 0
# Now we move the cursor left or right.
if plotter in [Axes.plot, Axes.errorbar]:
_process_event("__mouse_click__", ax, (.5, .5), 1)
assert tuple(cursor.selections[0].target) == approx((.5, .5))
_process_event("key_press_event", ax, (.123, .456), "shift+up")
_process_event("key_press_event", ax, (.123, .456), "shift+left")
elif plotter is Axes.scatter:
_process_event("__mouse_click__", ax, (0, 0), 1)
_process_event("key_press_event", ax, (.123, .456), "shift+up")
assert tuple(cursor.selections[0].target) == (0, 0)
assert cursor.selections[0].target.index == 0
_process_event("key_press_event", ax, (.123, .456), "shift+right")
assert tuple(cursor.selections[0].target) == (1, 1)
assert cursor.selections[0].target.index == 1
# Skip through nan.
_process_event("key_press_event", ax, (.123, .456), "shift+right")
assert tuple(cursor.selections[0].target) == (0, 0)
assert cursor.selections[0].target.index == 0
示例2: _register_scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def _register_scatter():
"""
Patch `PathCollection` and `scatter` to register their return values.
This registration allows us to distinguish `PathCollection`s created by
`Axes.scatter`, which should use point-like picking, from others, which
should use path-like picking. The former is more common, so we store the
latter instead; this also lets us guess the type better if this module is
imported late.
"""
@functools.wraps(PathCollection.__init__)
def __init__(self, *args, **kwargs):
_nonscatter_pathcollections.add(self)
return __init__.__wrapped__(self, *args, **kwargs)
PathCollection.__init__ = __init__
@functools.wraps(Axes.scatter)
def scatter(*args, **kwargs):
paths = scatter.__wrapped__(*args, **kwargs)
with suppress(KeyError):
_nonscatter_pathcollections.remove(paths)
return paths
Axes.scatter = scatter
示例3: scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None,
vmax=None, alpha=None, linewidths=None, verts=None, hold=None,
**kwargs):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
if hold is not None:
ax.hold(hold)
try:
ret = ax.scatter(x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
vmin=vmin, vmax=vmax, alpha=alpha,
linewidths=linewidths, verts=verts, **kwargs)
draw_if_interactive()
finally:
ax.hold(washold)
sci(ret)
return ret
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
示例4: gci
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
"""
return gcf()._gci()
## Any Artist ##
# (getp is simply imported)
示例5: scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None,
vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
hold=None, data=None, **kwargs):
ax = gca()
# Deprecated: allow callers to override the hold state
# by passing hold=True|False
washold = ax._hold
if hold is not None:
ax._hold = hold
from matplotlib.cbook import mplDeprecation
warnings.warn("The 'hold' keyword argument is deprecated since 2.0.",
mplDeprecation)
try:
ret = ax.scatter(x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
vmin=vmin, vmax=vmax, alpha=alpha,
linewidths=linewidths, verts=verts,
edgecolors=edgecolors, data=data, **kwargs)
finally:
ax._hold = washold
sci(ret)
return ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
示例6: test_scatter_text
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def test_scatter_text(ax):
ax.scatter([0, 1], [0, 1], c=[2, 3])
cursor = mplcursors.cursor()
_process_event("__mouse_click__", ax, (0, 0), 1)
assert _parse_annotation(
cursor.selections[0], "x=(.*)\ny=(.*)\n\[(.*)\]") == (0, 0, 2)
示例7: _
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def _(artist, event):
offsets = artist.get_offsets()
paths = artist.get_paths()
if _is_scatter(artist):
# Use the C implementation to prune the list of segments -- but only
# for scatter plots as that implementation is inconsistent with Line2D
# for segment-like collections (matplotlib/matplotlib#17279).
contains, info = artist.contains(event)
if not contains:
return
inds = info["ind"]
offsets = artist.get_offsets()[inds]
offsets_screen = artist.get_offset_transform().transform(offsets)
ds = np.hypot(*(offsets_screen - [event.x, event.y]).T)
argmin = ds.argmin()
target = _with_attrs(
_untransform(offsets[argmin], offsets_screen[argmin], artist.axes),
index=inds[argmin])
return Selection(artist, target, ds[argmin], None, None)
else:
# Note that this won't select implicitly closed paths.
sels = [*filter(None, [
_compute_projection_pick(
artist,
Affine2D().translate(*offsets[ind % len(offsets)])
.transform_path(paths[ind % len(paths)]),
(event.x, event.y))
for ind in range(max(len(offsets), len(paths)))])]
if not sels:
return None
idx = min(range(len(sels)), key=lambda idx: sels[idx].dist)
sel = sels[idx]
if sel.dist >= artist.get_pickradius():
return None
sel = sel._replace(artist=artist)
sel.target.index = (idx, sel.target.index)
return sel
示例8: gci
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
"""
return gcf()._gci()
示例9: scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def scatter(
x, y, s=None, c=None, marker=None, cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None, verts=None,
edgecolors=None, *, data=None, **kwargs):
__ret = gca().scatter(
x=x, y=y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,
verts=verts, edgecolors=edgecolors, data=data, **kwargs)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
示例10: scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def scatter(
x, y, s=None, c=None, marker=None, cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None, verts=None,
edgecolors=None, *, data=None, **kwargs):
__ret = gca().scatter(
x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,
verts=verts, edgecolors=edgecolors, **({"data": data} if data
is not None else {}), **kwargs)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
示例11: gci
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def gci():
"""
Get the current colorable artist. Specifically, returns the
current :class:`~matplotlib.cm.ScalarMappable` instance (image or
patch collection), or *None* if no images or patch collections
have been defined. The commands :func:`~matplotlib.pyplot.imshow`
and :func:`~matplotlib.pyplot.figimage` create
:class:`~matplotlib.image.Image` instances, and the commands
:func:`~matplotlib.pyplot.pcolor` and
:func:`~matplotlib.pyplot.scatter` create
:class:`~matplotlib.collections.Collection` instances. The
current image is an attribute of the current axes, or the nearest
earlier axes in the current figure that contains an image.
Notes
-----
Historically, the only colorable artists were images; hence the name
``gci`` (get current image).
"""
return gcf()._gci()
## Any Artist ##
# (getp is simply imported)
示例12: scatter
# 需要導入模塊: from matplotlib.axes import Axes [as 別名]
# 或者: from matplotlib.axes.Axes import scatter [as 別名]
def scatter(
x, y, s=None, c=None, marker=None, cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None, verts=None,
edgecolors=None, *, plotnonfinite=False, data=None, **kwargs):
__ret = gca().scatter(
x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,
verts=verts, edgecolors=edgecolors,
plotnonfinite=plotnonfinite, **({"data": data} if data is not
None else {}), **kwargs)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.