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: Fix example for what's new imshow so it isn't cut off or crowded.#24441

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

Conversation

stefmolin
Copy link
Contributor

@stefmolinstefmolin commentedNov 12, 2022
edited
Loading

PR Summary

The example for the What's new entry on theextent parameter toimshow currently has a very crowded y-axis and the labels are being cut off:
Screen Shot 2022-11-12 at 1 45 55 PM

I reduced the number of major ticks and adjusted the figure size in addition to callingtight_layout() to fix this. It now looks like the below in thebuilt docs.
Screen Shot 2022-11-12 at 2 21 16 PM

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (andpytest passes).
  • [N/A] IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • [N/A] New plotting related features are documented with examples.

Release Notes

  • [N/A] New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • [N/A] API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • [N/A] Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

@stefmolinstefmolin marked this pull request as ready for reviewNovember 12, 2022 19:22
@jklymak
Copy link
Member

Suggest constrained layout and concise date formatter.

@stefmolin
Copy link
ContributorAuthor

By "concise date formatter", did you mean something like this? TBH this seems confusing...
Screen Shot 2022-11-12 at 4 29 03 PM

@jklymak
Copy link
Member

I prefer the concise locator version, but I'm biased...

@stefmolin
Copy link
ContributorAuthor

stefmolin commentedNov 12, 2022
edited
Loading

What about something like this?
Screen Shot 2022-11-12 at 5 51 54 PM

@jklymak
Copy link
Member

I'm not going to block on that, but I don't find having 00:00 next to the day all that useful.

@stefmolin
Copy link
ContributorAuthor

Since this example has so many ticks so close together, I think this helps avoid confusion of the ticks being multiline entries e.g.,Jan-10\n12:00 kind of looks like a single label because the axis is so dense, but it is actually two labelsJan-10 00:00 andJan-10 12:00. If anything, there is now a bonus of providing some ways to tweak the output ofConciseDateFormatter.

@stefmolin
Copy link
ContributorAuthor

stefmolin commentedNov 13, 2022
edited
Loading

Here's theupdated page in the docs. This is also 3.7#22230

Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

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

Looks 👍 - just two non-blocking suggestions. I think that having00:00 next to the date is better than having just the date.

Copy link
Member

@timhoffmtimhoffm left a comment
edited
Loading

Choose a reason for hiding this comment

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

Since this is about extents and not about date formatting, I propose to simplify the y ticks further:

  • reduce to only one major tick per day (more ticks don't make sense because you have only one image pixel per day)
  • thus, also don't activate minor ticks
  • set the date format to "%d/%m%y" (no hours)

@jklymak
Copy link
Member

If you simply do:

importmatplotlib.pyplotaspltimportnumpyasnpplt.rcParams['date.converter']='concise'fig,ax=plt.subplots(layout='constrained')date_first=np.datetime64('2020-01-01','D')date_last=np.datetime64('2020-01-11','D')arr= [[i+jforiinrange(10)]forjinrange(10)]ax.imshow(arr,origin='lower',extent=[1,11,date_first,date_last])

Without any monkeying with ticks or formatters, you get the pretty straight forward:
Figure_1

@timhoffm
Copy link
Member

timhoffm commentedNov 13, 2022
edited
Loading

I would even leave outplt.rcParams['date.converter'] = 'concise'. IMHO this is not making it better here. Having only the numbers 02..11 on the y-axis (and a bit weird 'Jan') makes it less clear that the extent has been set to dates. So better without it:

image

Optional: I also switched the x-extent from [1, 11], to [0, 10] because it looks slightly better to have ticks on the boundaries. But that's just a minor stylistic thing.

@stefmolin
Copy link
ContributorAuthor

I agree with@timhoffm – I will update the example.

@timhoffmtimhoffm added this to thev3.7.0 milestoneNov 14, 2022
@timhoffmtimhoffm merged commit1fa7467 intomatplotlib:mainNov 14, 2022
@stefmolinstefmolin deleted the imshow-extent-cutoff-whatsnew branchNovember 15, 2022 23:13
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

5 participants
@stefmolin@jklymak@timhoffm@dstansby@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp