Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add marker-only and line+marker visuals to the plot() plot types #27771

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

timhoffm
Copy link
Member

Inspired from the discussion in #27765: We should visually communicate that plot() covers all three variants: markers only, line+markers, line-only. They are visually distinct enough that it's not possible to infer the variants if you see only one.

In particular, it's important to communicate that you can draw markers only. We don't want to automatically drive people who want markers (e.g. some discrete measurements of a dependent variable y (x)) to scatter because that's the only one showing discrete markers in the overview.

@github-actions github-actions bot added the Documentation: plot types files in galleries/plot_types label Feb 11, 2024
@timhoffm timhoffm added this to the v3.9.0 milestone Feb 11, 2024
@timhoffm
Copy link
Member Author

This shows as

image

See also the built docs

Inspired from the discussion in matplotlib#27765: We should visually communicate
that `plot()` covers all three variants: markers only,
line+markers, line-only.
They are visually distinct enough that it's not possible
to infer the variants if you see only one.
In particular, it's important to communicate that you
can draw markers only. We don't want to automatically drive people who
want markers (e.g. some discrete measurements of a dependent variable y
(x)) to scatter because that's the only one showing
 discrete markers in the overview.
Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

I think worth adding fmt= to be clear on what those arguments are doing, but feel free to take or leave that suggestion.


# plot
fig, ax = plt.subplots()

ax.plot(x2, y2 + 2.5, 'x', markeredgewidth=2)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ax.plot(x2, y2 + 2.5, 'x', markeredgewidth=2)
ax.plot(x2, y2 + 2.5, fmt='x', markeredgewidth=2)

ax.plot(x, y, linewidth=2.0)
ax.plot(x2, y2 - 2.5, 'o-', linewidth=2)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ax.plot(x2, y2 - 2.5, 'o-', linewidth=2)
ax.plot(x2, y2 - 2.5, fmt='o-', linewidth=2)

@ksunden
Copy link
Member

ksunden commented Feb 12, 2024

@dstansby passing fmt as a kwarg does not work, the x/y/fmt triples are positional-only args. each fmt applies to only one line and multiple lines may be plotted with a single call to plot.

@ksunden ksunden merged commit 402f41f into matplotlib:main Feb 12, 2024
@timhoffm timhoffm deleted the plot_types_plot branch February 12, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: plot types files in galleries/plot_types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants