Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
API: Polar: allow flipped y/rlims....#12300
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Devil's advocate here: (just about) everywhere else we are able to flip the order of the limits (particular favorite is pressure-as-height). Why shouldn't we be allowed to do something similar for polar plots? |
@WeatherGod Fine with me! But someone has to rewrite it so it works, which it does not right now... |
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.
If we plan to support an inverted axis at some point in the future, we should break with an error in that case for now.
While we can always move from an error to new functionality, going from auto-switching to inverted axis support would be a breaking change.
More philosophically, I feel that auto-switching may be too clever anyway. We can expect users to give the range in the correct order. If they don't, they either do it intentionally, because they expect a certain effect, or it's actually mistake, which might have other effects and go unnoticed because we corrected it for the plot ("but the plot looked correct").
So, I'm -1 on auto-switching.
That makes sense. I’m fine w an error and if someone wants to implement inverted axes they can do so in future |
I agree with@timhoffm here. You don't need to implement axis inversion here, but if you allow arbitrary order now, it'll be hard to allow for axis inversion via The error might point towards a possible workaround for now. For the r axis: "To mimic an inverted r-axis plot data.max()-data and set the ticklabels accordingly.". For theta axis: "Use |
Changed to a ValueError and changed the doc string to reflect thats what will happen. I don't know that we need to point out all the possible work arounds in an error message - they tend to be hard to describe in a line or two. But if you had something pithy, that'd be fine. |
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'm fine now with the functionality. Just some style issues.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/projections/polar.py Outdated
def set_rlim(self, *args, **kwargs): | ||
def set_rlim(self, bottom=None, top=None, emit=True, auto=False, **kwargs): | ||
""" | ||
See `~.polar.PolarAxes.set_ylim` |
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.
See~.polar.PolarAxes.set_ylim
. Additionally, you can passrmin/rmax in place ofymin/ymax.
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.
?? Not following this. We are trying to deprecate rmin, ymin etc. (Well, I don't agree with calling them bottom and top, but...)
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.
Thought to document the current state, even if it's deprecated (well, which should be mentioned then). But since this had no documentation at all so far. It's also ok to keep this a secret.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/axes/_base.py Outdated
right : scalar, optional | ||
The right xlim (default: None, which leaves the right limit | ||
The right xlim (default:``None``, which leaves the right limit |
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.
We don't have a consistent policy for None, True, False so far.
There are all styles present in our docs:
- plain
- literal: double backticks
- italics: starred
Personally, I find double backslashes too cumbersome to type and visually too broad in plain text for there short words. I just use*None*
.
Thenumpydoc andsphinx examples just use plain text.
Just mentioning. Since we currently have no standards, I won't hold this up.
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.
Happy to adopt whatever standard folks like the best, or to start a standard! It was plain before, happy to put it back.
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.
... and I note I missed about half of them. Switched back to plain text.
5ff37d9
to6d60d02
CompareAdded a small test for ValueError.... |
9b195c2
to24ca248
Comparesquashed and rebased |
It looks like this used to work with inverted axes, but we broke it (likely inadvertently) in the polar refactor. I think we should look into fixing it before we make it raise. |
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.
We should at least investigate why this broke.
Auto-inverting the axis direction for rectilinear plots (for better or worse), I don't see why radial plots should be different.
Fair enough. I didn’t know it used to work. I’ll clowe and we can reopen if we decide we can’t fix it. |
Thomas, I think the issue with polar plots came about partly because wecouldn't agree what to do about negative values, or radial limits thatdidn't start with 0.And allowing the bottom of a rectilinear plot to be 1000mb, and the top ofthe plot to be 10mb lets us all breathe! …On Sat, Sep 29, 2018 at 5:17 PM Thomas A Caswell ***@***.***> wrote: ***@***.**** requested changes on this pull request. We should at least investigate why this broke. Auto-inverting the axis direction for rectilinear plots (for better or worse), I don't see why radial plots should be different. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#12300 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARy-EQj2_BB8_NE4b8wAp2HR7GdDYbwks5uf-N0gaJpZM4W7Wvv> . |
I don’t see any reason inverting the axis is difficult mathematically. I just assumed it wasn’t working on purpose. |
I was confused by SO answers, I am not sure this ever worked anymore...
I just tested all they way back to 1.5 and this never actually worked (but silently kept going). Sorry for the noise 🐑 . |
jklymak commentedSep 29, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
No problem - but OTOH, I don't actually see why thiscan't work. Marking WIP while I take a quick look... |
b088df1
tod4d5eaa
Comparejklymak commentedSep 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
d4d5eaa
toa50a69d
CompareClearing because the PR is now not just raising an error
a50a69d
toc175663
Comparec175663
to90bcdaa
Compare90bcdaa
to5d1cdb1
CompareRebased.... |
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.
Only some minor comments for now.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Something funny happens if you flip the radial limits after a draw: #!/usr/bin/env pythonimportnumpyasnpimportmatplotlib.pyplotaspltfig, (ax0,ax1,ax2)=plt.subplots(1,3,subplot_kw=dict(polar=True))ax0.plot([0,1], [-1,1])ax0.scatter([0,1], [-1,1])ax0.set_rmin(-1.5)ax0.set_rmax(1.5)ax0.set_title('Forward')ax1.plot([0,1], [-1,1])ax1.scatter([0,1], [-1,1])ax1.set_rmin(1.5)ax1.set_rmax(-1.5)ax1.set_title('Backward')ax2.plot([0,1], [-1,1])ax2.scatter([0,1], [-1,1])ax2.set_rmin(-1.5)ax2.set_rmax(1.5)ax2.set_title('Backward with draw')fig.canvas.draw()ax2.set_rmin(1.5)ax2.set_rmax(-1.5)plt.show() |
@QuLogic Agreed, but that predates this PR, and is a different issue. On master: importnumpyasnpimportmatplotlib.pyplotaspltfig, (ax0,ax2)=plt.subplots(1,2,subplot_kw=dict(polar=True))ax0.plot([0,1], [-1,1])ax0.scatter([0,1], [-1,1])ax0.set_rmin(-1.5)ax0.set_rmax(1.5)ax0.set_title('Forward')ax2.plot([0,1], [-1,1])ax2.scatter([0,1], [-1,1])ax2.set_rmin(-1.5)ax2.set_rmax(1.5)ax2.set_title('draw; change rlims')fig.canvas.draw()ax2.set_rmin(0)ax2.set_rmax(1.5)plt.show() |
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.
Some typos to fix, but otherwise good to go.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
40f60a6
to4c71285
Compare4c71285
to3ecd588
CompareTypos fixed - this has two approvals and could be merged if anyone has a minute... |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Closes#11202
Closes#10704
Update
Allow non-increasing ylimits:
OLD:
This adds a check for set_ylim in polar to make sure they are in order and swap and emit an error if they are not. Because I had to overload
axes.set_ylim
I changed the argument handling a bit (hopefully correctly).Fixes a typo in
axes/_base.py
PR Checklist