Skip to content

DOC: Remove "Multiple lines using pyplot"#31705

Merged
rcomer merged 1 commit into
matplotlib:mainfrom
timhoffm:doc-remove-pyplot-multiple-lines
May 19, 2026
Merged

DOC: Remove "Multiple lines using pyplot"#31705
rcomer merged 1 commit into
matplotlib:mainfrom
timhoffm:doc-remove-pyplot-multiple-lines

Conversation

@timhoffm
Copy link
Copy Markdown
Member

We should not promote the specific plot(x, y, fmt, x2, y2, fmt) anymore. This is a Matlabism and hard to read and reason about. Separate plot() calls are the better option. They don't need a dedicated pyplot example. Therefore, a redirect to the pyplot subplot example is sufficient, which as a side-topic has two plot calls in one subplot.

While at it, I improved the description of the peplos subplot example.

@github-actions github-actions Bot added the Documentation: examples files in galleries/examples label May 19, 2026
@timhoffm timhoffm force-pushed the doc-remove-pyplot-multiple-lines branch from 6025ef7 to 9704c63 Compare May 19, 2026 10:48
Comment thread galleries/examples/pyplots/pyplot_two_subplots.py Outdated
@rcomer
Copy link
Copy Markdown
Member

rcomer commented May 19, 2026

Very early in my python learning days I was told that the pattern plt.subplot(211) is not nice and it's better to use plt.subplot(2, 1, 1) because these are explicit parameters. Do you have any opinion on that?

=========================

Create a figure with two subplots using `.pyplot.subplot`.
In pyplot, subplots are created incrementally through `~.pyplot.subplot`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
In pyplot, subplots are created incrementally through `~.pyplot.subplot`.
In pyplot, subplots can be created incrementally through `~.pyplot.subplot`.

?

There is nothing to stop you creating them all at once with subplots or subplot_mosaic and then sca to control where you are plotting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reworded to

A typical pyplot usage pattern is to create subplots incrementally through ...

Comment thread galleries/examples/pyplots/pyplot_two_subplots.py Outdated
@timhoffm
Copy link
Copy Markdown
Member Author

Very early in my python learning days I was told that the pattern plt.subplot(211) is not nice and it's better to use plt.subplot(2, 1, 1) because these are explicit parameters. Do you have any opinion on that?

I agree for formal code, e.g. in fig.add_subplot(2, 1, 1). But pyplot is the implicit, shortcut, quick-typing convenience layer, and there 211 seems fine. If I was using multiple subplots with pyplot (which I usually don't) I would take the shorcut.

We should not promote the specific `plot(x, y, fmt, x2, y2, fmt)` anymore. This is a Matlabism and hard to read and reason about. Separate `plot()` calls are the better option. They don't need a dedicated pyplot example. Therefore, a redirect to the pyplot subplot example is sufficient, which as a side-topic has two plot calls in one subplot.

Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@timhoffm timhoffm force-pushed the doc-remove-pyplot-multiple-lines branch from eaa3573 to 6fc1020 Compare May 19, 2026 18:51
@rcomer rcomer added this to the v3.11.0 milestone May 19, 2026
@rcomer rcomer merged commit 4946ac3 into matplotlib:main May 19, 2026
21 checks passed
@timhoffm timhoffm deleted the doc-remove-pyplot-multiple-lines branch May 19, 2026 19:23
QuLogic added a commit that referenced this pull request May 19, 2026
…705-on-v3.11.x

Backport PR #31705 on branch v3.11.x (DOC: Remove "Multiple lines using pyplot")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: examples files in galleries/examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants