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

[ENH] Add data parameter in Axes3D.plot#30270

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

Open
vagnermcj wants to merge19 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromvagnermcj:new_feature_issue_30238
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
b468641
Add data parameters to plot function in axes3d + add test for data pl…
livlutzJul 5, 2025
58a7d21
Test Handling
vagnermcjJul 6, 2025
b2f9714
Refactor test_plot_data to use explicit lists for coordinates
livlutzJul 6, 2025
ca0629b
Merge branch 'new_feature_issue_30238' of https://github.com/vagnermc…
livlutzJul 6, 2025
ef4216c
Refactor test_plot_data to use explicit lists for coordinates
livlutzJul 6, 2025
ece6b0e
Merge branch 'matplotlib:main' into new_feature_issue_30238
livlutzJul 6, 2025
809e804
Test adjustments
vagnermcjJul 7, 2025
c451c29
new test checking
vagnermcjJul 7, 2025
edb05b7
CI Fix
vagnermcjJul 7, 2025
93469e7
CI docstring fix
vagnermcjJul 7, 2025
e75e13b
implemented test plot data
BrunoWolf03Jul 7, 2025
1d8d69d
Merge branch 'matplotlib:main' into new_feature_issue_30238
livlutzJul 8, 2025
c0b2bf7
Adding API change notes to plot method in Axes3D class
livlutzJul 8, 2025
688e153
Using the preprocess data decorator fot the axes3d method
livlutzJul 9, 2025
34cd222
Refactor plot method in Axes3D class to simplify parameter handling
livlutzJul 9, 2025
0598149
Merge branch 'matplotlib:main' into new_feature_issue_30238
livlutzJul 9, 2025
83157fa
Merge branch 'matplotlib:main' into new_feature_issue_30238
livlutzJul 10, 2025
98b9c66
Refactor plot doc + test with implicit zs=0
livlutzJul 10, 2025
0c04c8a
Update Axes3D.plot docstring to clarify parameter types and signature…
livlutzJul 10, 2025
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
37 changes: 19 additions & 18 deletionslib/mpl_toolkits/mplot3d/axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1963,43 +1963,44 @@ def text(self, x, y, z, s, zdir=None, *, axlim_clip=False, **kwargs):
text3D = text
text2D = Axes.text

def plot(self, xs, ys, *args, zdir='z', axlim_clip=False, **kwargs):
@_preprocess_data(replace_names=['xs', 'ys', 'zs'])
def plot(self, xs, ys, zs=0, fmt=None, *, zdir='z', axlim_clip=False, **kwargs):
"""
Plot 2D or 3D data.

Parameters
----------
.. versionchanged:: 3.10
xs : 1D array-like
x coordinates of vertices.
ys : 1D array-like
y coordinates of vertices.
zs : float or 1D array-like
z coordinates of vertices; either one for all points or one for
each point.
The signature was changed to make the parameters *zs* and *fmt* explicit.

The unconventional but previously valid call signature
``plot(xs, ys, 'ro', zs=zs)`` is no longer supported.

Parameters
----------
zdir : {'x', 'y', 'z'}, default: 'z'
When plotting 2D data, the direction to use as z.
axlim_clip : bool, default: False
Whether to hide data that is outside the axes view limits.

.. versionadded:: 3.10
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
Other arguments are forwarded to`matplotlib.axes.Axes.plot`.
Other arguments are forwarded to'Axes.plot'.
Comment on lines -1971 to +1993
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Um, you've significantly mixed up the docstring:

  • moved the..versionchanged:: 3.10 fromaxlim_clip to the top
  • moved thexs,ys,zs out of theParameters section
  • Removed the link in**kwargs

Please take more care when submitting changes. These are all aspects that you should have been able to detect yourself and not something we should be spending valuable reviewer time on.

"""
had_data = self.has_data()

# `zs` can be passed positionally or as keyword; checking whether
# args[0] is a string matches the behavior of 2D `plot` (via
# `_process_plot_var_args`).
if args and not isinstance(args[0], str):
zs, *args = args
if 'zs' in kwargs:
raise TypeError("plot() for multiple values for argument 'zs'")
else:
zs = kwargs.pop('zs', 0)

xs, ys, zs = cbook._broadcast_with_masks(xs, ys, zs)

lines = super().plot(xs, ys, *args, **kwargs)
if fmt is not None:
lines = super().plot(xs, ys, fmt, **kwargs)
else:
lines = super().plot(xs, ys, **kwargs)

for line in lines:
art3d.line_2d_to_3d(line, zs=zs, zdir=zdir, axlim_clip=axlim_clip)

Expand DownExpand Up@@ -4042,7 +4043,7 @@ def stem(self, x, y, z, *, linefmt='C0-', markerfmt='C0o', basefmt='C3-',
linestyle = mpl._val_or_rc(linestyle, 'lines.linestyle')

# Plot everything in required order.
baseline, = self.plot(basex, basey,basefmt,zs=bottom,
baseline, = self.plot(basex, basey, zs=bottom, fmt=basefmt,
zdir=orientation, label='_nolegend_')
stemlines = art3d.Line3DCollection(
lines, linestyles=linestyle, colors=linecolor, label='_nolegend_',
Expand Down
14 changes: 12 additions & 2 deletionslib/mpl_toolkits/mplot3d/tests/test_axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -346,9 +346,19 @@
@check_figures_equal()
def test_plot_scalar(fig_test, fig_ref):
ax1 = fig_test.add_subplot(projection='3d')
ax1.plot([1], [1], "o")
ax1.plot([1], [1], [1], "o")
ax1.plot([2], [2], "o")
ax2 = fig_ref.add_subplot(projection='3d')
ax2.plot(1, 1, "o")
ax2.plot(1, 1, 1, "o")
ax2.plot(2, 2, 0, "o")

Check warning on line 353 in lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

View check run for this annotation

Codecov/ codecov/patch

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py#L352-L353

Added lines #L352 - L353 were not covered by tests


@check_figures_equal()
def test_plot_data(fig_test, fig_ref):
ax1 = fig_test.add_subplot(projection='3d')
ax1.plot([1, 2, 3], [4, 5, 6], [7, 8, 9])
ax2 = fig_ref.add_subplot(projection='3d')
ax2.plot([1, 2, 3], [4, 5, 6], [7, 8, 9])


def test_invalid_line_data():
Expand Down
4 changes: 2 additions & 2 deletionslib/mpl_toolkits/mplot3d/tests/test_legend3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,8 @@
def test_legend_plot():
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
x = np.arange(10)
ax.plot(x, 5 - x, 'o', zdir='y', label='z=1')
ax.plot(x, x - 5, 'o', zdir='y', label='z=-1')
ax.plot(x, 5 - x,0, fmt='o', zdir='y', label='z=1')
ax.plot(x, x - 5,0, fmt='o', zdir='y', label='z=-1')
ax.legend()


Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp