-
Notifications
You must be signed in to change notification settings - Fork 30
Add a (skippable) check that the axes have equal aspect ratio. #61
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
Conversation
README.md
Outdated
By default, matplotlib_scalebar checks whether the axes have equal aspect ratio | ||
(so that the scale bar applies both for the x and the y directions), and emits | ||
a warning if this is not the case. This warning can be suppressed by setting | ||
*rotation* to `horizontal-only` ("the colorbar only applies to the horizontal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colorbar? Shouldn't it be "scale bar"?
README.md
Outdated
(so that the scale bar applies both for the x and the y directions), and emits | ||
a warning if this is not the case. This warning can be suppressed by setting | ||
*rotation* to `horizontal-only` ("the colorbar only applies to the horizontal | ||
direction") or `vertical-only` ("the colorbar only applies to the vertical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
matplotlib_scalebar/test_scalebar.py
Outdated
@@ -33,7 +35,7 @@ def scalebar(): | |||
|
|||
yield scalebar | |||
|
|||
plt.draw() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the draw is important here to make sure the scale bar is drawn. It doesn't look that it will impact your unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. I agree having a warning when the aspect ratio is not 1 would be useful, as 99% of the time the scale bar will be used on plots with an aspect ratio of 1.
When the scalebar is not drawn on an aspect where imshow() has been called (e.g., a point cloud made with plot()), the axes aspect ratio is not automatically set to 1, in which case the scale bar will be wrong (or rather, it will only be correct in the direction (horizontal or vertical) in which it is drawn). To avoid mistakes, add a check for the aspect ratio, emitting a warning when appropriate. The check can be skipped by using new variants for `rotation`: it can now be set to "horizontal-only" ("the scalebar only applies to the horizontal direction") or "vertical-only". (This could also have been a separate kwarg, but something like `check_aspect=False` reads a bit awkwardly to me.)
Thanks, I addressed your comments. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #61 +/- ##
==========================================
- Coverage 91.46% 89.93% -1.54%
==========================================
Files 3 3
Lines 422 437 +15
==========================================
+ Hits 386 393 +7
- Misses 36 44 +8 ☔ View full report in Codecov by Sentry. |
…rd#61) * Add a (skippable) check that the axes have equal aspect ratio. When the scalebar is not drawn on an aspect where imshow() has been called (e.g., a point cloud made with plot()), the axes aspect ratio is not automatically set to 1, in which case the scale bar will be wrong (or rather, it will only be correct in the direction (horizontal or vertical) in which it is drawn). To avoid mistakes, add a check for the aspect ratio, emitting a warning when appropriate. The check can be skipped by using new variants for `rotation`: it can now be set to "horizontal-only" ("the scalebar only applies to the horizontal direction") or "vertical-only". (This could also have been a separate kwarg, but something like `check_aspect=False` reads a bit awkwardly to me.) * Try to fix CI --------- Co-authored-by: Philippe Pinard <philippe.pinard@gmail.com>
…rd#61) * Add a (skippable) check that the axes have equal aspect ratio. When the scalebar is not drawn on an aspect where imshow() has been called (e.g., a point cloud made with plot()), the axes aspect ratio is not automatically set to 1, in which case the scale bar will be wrong (or rather, it will only be correct in the direction (horizontal or vertical) in which it is drawn). To avoid mistakes, add a check for the aspect ratio, emitting a warning when appropriate. The check can be skipped by using new variants for `rotation`: it can now be set to "horizontal-only" ("the scalebar only applies to the horizontal direction") or "vertical-only". (This could also have been a separate kwarg, but something like `check_aspect=False` reads a bit awkwardly to me.) * Try to fix CI --------- Co-authored-by: Philippe Pinard <philippe.pinard@gmail.com>
When the scalebar is not drawn on an aspect where imshow() has been called (e.g., a point cloud made with plot()), the axes aspect ratio is not automatically set to 1, in which case the scale bar will be wrong (or rather, it will only be correct in the direction (horizontal or vertical) in which it is drawn).
To avoid mistakes, add a check for the aspect ratio, emitting a warning when appropriate. The check can be skipped by using new variants for
rotation
: it can now be set to "horizontal-only" ("the scalebar only applies to the horizontal direction") or "vertical-only". (This could also have been a separate kwarg, but something likecheck_aspect=False
reads a bit awkwardly to me -- let me know if you'd prefer that.)