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

DOC: multilevel tick example#27411

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

Merged
jklymak merged 2 commits intomatplotlib:mainfromjklymak:doc-multilevel-ticks
Dec 2, 2023

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedDec 1, 2023
edited
Loading

This adds an example showing one method of adding multilevel ticks to a plot.

multilevel

Not a substitute for#6321, but shows that it's possible with minimal fussing. Also partially addresses#27394, or at least gives an example of how to achieve the date axis effect discussed there

@jklymakjklymakforce-pushed thedoc-multilevel-ticks branch 2 times, most recently frome52f7d4 toc39134bCompareDecember 1, 2023 17:04
Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

Nicely done. I particularly like the progression from simple to complicated example, so the reader can see how it builds up.

My comments are all very picky, so please take or leave any of them.

# label the months:
sec = ax.secondary_xaxis(location=-0.075)
sec.xaxis.set_major_locator(mdates.MonthLocator(bymonthday=1))
sec.xaxis.set_major_formatter(mdates.DateFormatter(' %b'))
Copy link
Member

Choose a reason for hiding this comment

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

I assume you add the spaces before the%b to improve the alignment with the tick. I just spent longer than I care to admit trying to figure out a way to set the horizontal alignment of the labels, and now I think I understand why you want to overhaulAxis!

For the record, this works, but I'm not sure it would be an improvement.

fig.draw_without_rendering()# Otherwise only one label exists to loop through.  Is there a cheaper way to force tick generation?forlabelinsec.xaxis.get_ticklabels():label.set_horizontalalignment('left')

Is it worth a comment to explain the spaces though?

jklymak reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, it's all pretty annoying. And of course that alignment only holds for ticks that presently exist - if you pan off to right or left the new ticks won't get the alignment.

rcomer reacted with thumbs up emoji
Copy link
Member

@story645story645Dec 2, 2023
edited
Loading

Choose a reason for hiding this comment

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

aI think lighter lift to improve this would be to add alignment totick_params#20644

rcomer reacted with thumbs up emoji
# This example also differs from the above, in that we placed it at a
# location below the main axes ``location=-0.075`` and then we hide the spine
# by setting the line width to zero. That means that our formatter no longer
# needs the carriage returns of the previous two examples.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a sentence near the top somewhere to explain why wedo add the "\n" in those examples.

jklymak reacted with thumbs up emoji

ax.plot(['cats', 'dogs', 'pigs', 'snakes', 'lizards', 'chickens',
'eagles', 'herons', 'buzzards'],
rng.normal(size=9))
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
rng.normal(size=9))
rng.normal(size=9),'o')

I know it doesn't matter a jot for the purpose of the example, but lines between categorical data don't make sense to me.

jklymak reacted with thumbs up emoji
sec.set_xticks([5, 15, 25], labels=['\nOughts', '\nTeens', '\nTwenties'])

# %%
# This example adds a second level of annotation to a categorical axis. Note
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
#This example adds a second level of annotation to a categorical axis. Note
#The second example adds a second level of annotation to a categorical axis. Note

To make it really obvious to the reader that we are moving on.

jklymak reacted with thumbs up emoji
Comment on lines 36 to 37
# This example adds a second level of annotation to a categorical axis. Note
# that here we need to note that each animal (category) is assigned an integer,
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
# This example adds a second level of annotation to a categorical axis. Note
#that here we need to note that each animal (category) is assigned an integer,
# This example adds a second level of annotation to a categorical axis.
#Here we need to note that each animal (category) is assigned an integer,

Scans a little better for me.


# %%
# Dates are another common place where we may want to have a second level of tick
# labels. Here we take advantage of the ability to add an automatic locator and
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
# labels.Here we take advantage of the ability to add an automatic locator and
# labels.Next we take advantage of the ability to add an automatic locator and

Moving on again.

jklymak reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

"In this last example,"

rcomer reacted with thumbs up emoji
`development version <https://matplotlib.org/devdocs/devel/index.html>`_
of this document as it will have the most up to date installation
instructions, workflow process, and contributing guidelines.

Copy link
Member

Choose a reason for hiding this comment

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

Where did this come from? I didn't see it before and it doesn't show in the "force-push" diff 😕

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I've had that happen for this PR a couple of times where changes on main get shown as diffs in this PR? Not sure why, but a rebase on main fixes it

rcomer reacted with thumbs up emoji
fix typoCo-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@jklymakjklymak merged commitd8e272f intomatplotlib:mainDec 2, 2023
@jklymakjklymak deleted the doc-multilevel-ticks branchDecember 2, 2023 22:36
@rcomerrcomer added this to thev3.8-doc milestoneDec 3, 2023
@rcomer
Copy link
Member

@meeseeksdev backport to v3.8.x

@rcomer
Copy link
Member

@meeseeksdev backport to v3.8.2-doc

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestDec 3, 2023
rcomer added a commit that referenced this pull requestDec 3, 2023
…411-on-v3.8.2-docBackport PR#27411 on branch v3.8.2-doc (DOC: multilevel tick example)
rcomer added a commit that referenced this pull requestDec 3, 2023
…411-on-v3.8.xBackport PR#27411 on branch v3.8.x (DOC: multilevel tick example)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@story645story645story645 left review comments

@rcomerrcomerrcomer approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
v3.8-doc
Development

Successfully merging this pull request may close these issues.

3 participants
@jklymak@rcomer@story645

[8]ページ先頭

©2009-2025 Movatter.jp