8000 Add stackplot to plot types listing by story645 · Pull Request #23062 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add stackplot to plot types listing #23062

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
May 30, 2022
Merged

Conversation

story645
Copy link
Member
@story645 story645 commented May 18, 2022

Area plots (stackplots) are a fairly common plot type, so I figure should be included in the plot type listing. They're structurally similar to fill_between, which is why I put this in the same 'basic' section

eta: no idea why my rebase/squash isn't working (it is locally) so folks are welcome squash.
eta2: no idea what combination of button mashing got me to a clean commit

@jklymak
Copy link
Member
jklymak commented May 18, 2022

I'm not in favour of plot_types being an exhaustive list -- its meant to be a quick reference for what Matplotlib can do. In particular stackplot is just a convenience wrapper around fill_between, so it should be obvious already that we can make them.

@story645
Copy link
Member Author
story645 commented May 18, 2022

I agree that it shouldn't be an exhaustive list of axes methods, and I agree that it should be a quick reference, but I think of it as being akin to excel's chart types directory and that it is mostly a reference for the methods on axes that are the charts Matplotlib makes out of the box.

I think an area plot is conceptually unique enough to warrant its own entry. For example, if a user wanted to make an area plot, it's far more likely we'd direct them to ax.stackplot than to fill between.
I think that stackplot = loop fill_between could just as easily apply to stem, which is listed in plot_types and can be implemented as vlines + scatter

@jklymak
Copy link
Member
jklymak commented May 18, 2022

Yes, I could easily be convinced to remove stem as well; the original list was just the cheatsheet plots. I still think stacked fill-betweens is too much like fill_between to get its own "plot_type" and we already have fill_between in the list.

@oscargus
Copy link
Member

is just a convenience wrapper

I'd argue for the opposite. "Plot types" is a brilliant starting point to see how one can easily do things. So even though some functions are only wrappers, they are wrappers for something (hopefully) useful. So for a new user to see all these examples is much easier that trying to figure out that e.g. a stem-plot can be created using two separate plots (which they may try to do if stem is not there).

With the reservation that we probably should try to keep the list reasonably short, but stackplot (and stairs) has two slots nicely allocated for them...

@story645 story645 marked this pull request as draft May 18, 2022 16:45
@story645 story645 force-pushed the plot-types branch 3 times, most recently from ce6298e to b2c2372 Compare May 18, 2022 19:39
@story645 story645 marked this pull request as ready for review May 18, 2022 21:18
# plot
fig, ax = plt.subplots()

ax.stackplot(x, y, labels=labels)
Copy link
Member

Choose a reason for hiding this comment

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

The current colours are quite stark compared to the rest of this section, though they are the same as the next section, so maybe it is OK? If it were me, I'd apply an alpha, probably in the cycle?

I clicked through to stackplot and its description of the y parameter is somewhat enigmatic. I would not have assumed that the third plotted "line" was the cumulatively summed with the first two.

@timhoffm
Copy link
Member

@jklymak
Copy link
Member
jklymak commented May 24, 2022

Yeah, @story645 changed the color cycle

@story645
Copy link
Member Author
story645 commented May 24, 2022

Oops, I enabled the color cycle (it was turned off), but I can reverse the colors to be dark to light and that should make the other ones kick in? 8000 I guess before they were relying on the colormap but cycler takes precedence? (Is there a way to specify which artists should use which color cycle?

@jklymak
Copy link
Member
jklymak commented May 24, 2022

It was using the default color cycle before.

@story645
Copy link
Member Author
story645 commented May 24, 2022

It was using the default color cycle before.

not fill between - that's the one that confuses me see that fill_between just uses C0+alpha

ETA: had to change the color cycle to get stackplot in blues

@story645
Copy link
Member Author

And also this is what I'm using as the bases for the color cycle, based on breaking blues into 10 steps
image

Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Looks good, only some minor cleanup left.

@timhoffm timhoffm merged commit b66d00d into matplotlib:main May 30, 2022
@timhoffm
Copy link
Member

Thanks @story645!

@timhoffm timhoffm added this to the v3.6.0 milestone May 30, 2022
@story645 story645 deleted the plot-types branch May 30, 2022 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0