8000 Remove Axes sublists from docs by QuLogic · Pull Request #22279 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove Axes sublists from docs #22279

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 2 commits into from
Jan 25, 2022
Merged

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Jan 21, 2022

PR Summary

There are some bits of the tutorials that should have been changed to remove reference to modifying the Axes sublists.

Also remove the use of the sublists in the 'bar of pie' example, and improve its colours.

PR Checklist

Tests and Styling

  • [n/a] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [n/a] New features are documented, with examples if plot related.
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@QuLogic QuLogic added this to the v3.5.2 milestone Jan 21, 2022
@QuLogic QuLogic changed the title Remove Axes sublists froms docs Remove Axes sublists from docs Jan 21, 2022
@QuLogic QuLogic modified the milestones: v3.5.2, v3.5-doc Jan 21, 2022
Comment on lines 35 to 41
# Adding from the top matches the legend without have to explicitly re-order
# the legend.
for j, height in enumerate(reversed(approved_ratios)):
bottom -= height
bc = ax2.bar(0, height, width, bottom=bottom, color='C0',
alpha=0.1 + 0.25 * j)
ax2.bar_label(bc, labels=["%d%%" % (height * 100,)], label_type='center')
Copy link
Member

Choose a reason for hiding this comment

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

This breaks the association of approved_ratios to the legend labels.

Anyway, legend(labels) is a bad idea because you rely on the insertion order of artists.
I suggest you do

age_ratios = [.33, .54, .07, .06]
age_labels = ['Under 35', '35-49', '50-65', 'Over 65']
for j, height, label in ...:
    ....
    ax2.bar(..., label=label)

ax2.legend()

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean about breaking the association, but I applied the change anyway.

... by saving and using the results from Axes method calls. Also,
replace the colour palette in the bar chart.
@timhoffm timhoffm merged commit 813e5b0 into matplotlib:main Jan 25, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 25, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 25, 2022
@QuLogic QuLogic deleted the axes-sublist-docs branch January 25, 2022 21:13
QuLogic added a commit that referenced this pull request Jan 25, 2022
…279-on-v3.5.1-doc

Backport PR #22279 on branch v3.5.1-doc (Remove Axes sublists from docs)
QuLogic added a commit that referenced this pull request Jan 27, 2022
…279-on-v3.5.x

Backport PR #22279 on branch v3.5.x (Remove Axes sublists from docs)
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.

2 participants
0