Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Changed the return type of streamplot to a container object#24388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
story645 wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromstory645:streamcontainer
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletionlib/matplotlib/container.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import collections

from matplotlib import cbook
from matplotlib.artist import Artist

Expand All@@ -15,7 +17,12 @@ def __repr__(self):
.format(type(self).__name__, len(self)))

def __new__(cls, *args, **kwargs):
return tuple.__new__(cls, args[0])
if isinstance(args[0], collections.abc.Iterable):
iterable_of_artists = args[0]
else:
iterable_of_artists = (a for a in args if isinstance(a, Artist))

return tuple.__new__(cls, iterable_of_artists)

def __init__(self, kl, label=None):
self._callbacks = cbook.CallbackRegistry(signals=["pchanged"])
Expand Down
36 changes: 22 additions & 14 deletionslib/matplotlib/streamplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@

import matplotlib as mpl
from matplotlib import _api, cm, patches
from matplotlib.container import Container
import matplotlib.colors as mcolors
import matplotlib.collections as mcollections
import matplotlib.lines as mlines
Expand DownExpand Up@@ -76,17 +77,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,

Returns
-------
StreamplotSet
Container object with attributes
`~.StreamplotContainer`

- ``lines``: `.LineCollection` of streamlines

- ``arrows``: `.PatchCollection` containing `.FancyArrowPatch`
objects representing the arrows half-way along stream lines.

This container will probably change in the future to allow changes
to the colormap, alpha, etc. for both lines and arrows, but these
changes should be backward compatible.
.. versionchanged major.minor::
"""
grid = Grid(x, y)
mask = StreamMask(density)
Expand DownExpand Up@@ -237,20 +230,35 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
axes.add_patch(p)

axes.autoscale_view()
stream_container = StreamplotSet(lc, ac)
return stream_container
return StreamplotSet(lc, ac)


class StreamplotSet(Container):
"""
`~.Container` object for artists created in an `~.Axes.streamplot` plot.

It can be treated like a namedtuple with fields ``(lines, arrows)``

class StreamplotSet:
.. versionchanged major.minor ::

def __init__(self, lines, arrows):
Attributes
----------
lines: `~.LineCollection`
` collection of `.Line2d` segments that make up the streamlines
arrows: `~.PatchCollection`
collection of `.FancyArrow` arrows half-way along each streamline
"""

def __init__(self, lines, arrows, **kwargs):
self.lines = lines
self.arrows = arrows
super().__init__(lines, arrows, **kwargs)


# Coordinate definitions
# ========================


class DomainMap:
"""
Map representing different coordinate systems.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp