-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
so.Est() + tick label formatter => 'PseudoAxis' object has no attribute '_view_interval' #3585
Comments
A similar (but different) error is apparent when trying to use a import seaborn as sns
import seaborn.objects as so
import matplotlib as mpl
fmri = sns.load_dataset("fmri")
(
so.Plot(fmri, x="timepoint", y="signal", color="event")
.add(so.Band(), so.Est())
.scale(y=so.Continuous().tick(mpl.ticker.LogLocator()))
) Which errors the following
|
Probably the same underlying problem but @MaozGelbart I am curious what your usecase is for using a |
No such use case, just for ease of reproduction. Can reproduce with this code as well: import seaborn as sns
import seaborn.objects as so
import matplotlib as mpl
fmri = sns.load_dataset("fmri")
(
so.Plot(fmri, x="timepoint", y="signal", color="event")
.add(so.Band(), so.Est())
.scale(y=so.Continuous(trans="symlog").tick(locator=LogLocator()))
) |
OK got it, thanks! |
(I guess, follow-up question, did you have a usecase where |
In the objects interface symlog scale uses a different locator than log scale, so sometimes in this scenario it makes sense to change the locator into a logarithmic one. |
I think the culprit here is the cross-reference between locators and the axis they're associated with. During scale setup a shallow copy of the scale is performed: seaborn/seaborn/_core/scales.py Lines 419 to 427 in f0b48e8
This uses the same locator instance to setup the scale of the y variable and the scales of ymin and ymax . During PseudoAxis initialization for ymin and ymax (using the same copied Locator of YAxis ), the locator is informed of the Axis that contains it:seaborn/seaborn/_core/scales.py Lines 938 to 940 in f0b48e8
and because ymin and ymax are calculated after y scale has been created, the locator is stuck pointing to the last PseudoAxis created. During plotting, the locator is questioned about the axis it is contained within, and PseudoAxis implementation lacks some Axis members that are otherwise expected to be.Changing the copy operation to deepcopy results with new Locator instances during scale setup for ymin and ymax , so the original y scale locator keeps the reference to YAxis . If this solution is in the correct direction, I can draft a PR.
|
Hi, thanks for cool library, I especially enjoy using objects interface.
While using it I encountered a small issue when trying to customise tick labels using matplotlib formatter in combination with
so.Est()
. If I replace it withso.Agg()
the issue disappears. I guess this has something to do with the fact that several variables use the same scale (y/ymin/ymax) and_view_interval
is not initialised properly in that case?Versions:
seaborn: 0.13.0
matplotlib: 3.6.2
The text was updated successfully, but these errors were encountered: