Skip to content
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

Plots first and last minor ticks #22331 #24661

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

aalmasmari
Copy link

PR Summary

Resolves issue where first and last minor ticks do not appear, as mentioned in issue #22331

PR Checklist

Documentation and Tests

  • [ Yes ] Has pytest style unit tests (and pytest passes)
  • [ N/A ] Documentation is sphinx and numpydoc compliant (the docs should build 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 in doc/users/next_whats_new/
  • [ N/A ] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • [ N/A ] Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

lib/matplotlib/ticker.py Outdated Show resolved Hide resolved
@marisawong7 marisawong7 force-pushed the Plot-first-and-last-minor-ticks-#22331 branch from eafe72c to 6351b6a Compare December 10, 2022 23:05
@aalmasmari
Copy link
Author

We're failing test_colorbar.py::test_colorbar_minorticks_on_off, and below is the image produced before our changes.
original_test
Then, this is the image produced with our changes:
actual_test_result
How is our image wrong? It seems to make sense that there be an extra minor tick on the bottom given there is one above. Also, the test sets the limit at (-1.2, 1.2) but the test's expected output has the minor ticks start at -1.1 and end at 1.3. Why is this?

@aalmasmari aalmasmari force-pushed the Plot-first-and-last-minor-ticks-#22331 branch from 6351b6a to 229d116 Compare December 12, 2022 03:03
@aalmasmari aalmasmari marked this pull request as ready for review December 12, 2022 03:56
@dstansby
Copy link
Member

It looks like the failing test is failing because you've improved the output! The test sets the colorbar limits to -1.2, 1.2, but before your PR the ticks went from -1.1 to 1.3. With your PR, the ticks go from -1.2 to 1.2, which is better. So I think all that needs doing here is for you to update the list of expected ticks on line 399 in test_colorbar.py.

Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
@aalmasmari aalmasmari force-pushed the Plot-first-and-last-minor-ticks-#22331 branch from 229d116 to 5fa31c4 Compare January 24, 2023 19:05
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

Please rebase so that you get the latest CircleCI config.

lib/matplotlib/tests/test_ticker.py Outdated Show resolved Hide resolved
@rcomer rcomer linked an issue Jan 29, 2023 that may be closed by this pull request
@@ -106,6 +106,25 @@ def test_basic(self):
(1, 0) # a single major tick => no minor tick
]

def test_first_and_last_minorticks(self):
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little concerned that this didn't test before!

tmin = ((vmin - t0) // minorstep + 1) * minorstep
tmax = ((vmax - t0) // minorstep + 1) * minorstep
locs = np.arange(tmin, tmax, minorstep) + t0
tmin = round((vmin - t0) / minorstep)
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs an API change note. /doc/api/next_api_changes/behavior is the correct place for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[Bug]: First and or last minor ticks sometimes not plotted
6 participants