-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
y-axis label no longer obeys x position in 2.0 #7946
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
Comments
It would be useful to have an example that does not rely upon seaborn in
order to isolate the source of the bug. The bug could very well be in
seaborn's FacetGrid, for all we know...
…On Wed, Jan 25, 2017 at 11:49 AM, Roberto Rocha ***@***.***> wrote:
Using matplotlib with Seaborn's FacetGrid. Before upgrade to 2.0, setting
the x,y position of the y-axis label worked. Now only y-position is
respected.
import seaborn as snsimport matplotlib.pyplot as plt
g = (sns.FacetGrid(df, col="prenom", hue="sexe", col_wrap=3, size=3, sharey=False, legend_out=True)
.map(plt.plot, "annee", "freq", ms=3, linewidth=3))
g.set(xlim=(1980, 2015), xticks=[1980, 1990, 2000, 2010], ylim=0)
g.set_titles('{col_name}')
g.fig.subplots_adjust(top = 0.91, wspace=0.3, hspace=0.3)
g.set_titles('{col_name}', size=13, fontweight='bold', ha='left')
g.set_axis_labels('', 'BABIES')
### This is the line that is not working ###
g.set_ylabels(rotation=0, position=(0, 1.04), color='grey')
g.fig.suptitle('Names that changed gender', x = 0.1, ha='left')
sns.plt.legend(loc='upper left',bbox_to_anchor=(1.5,1))
sns.despine()
It doesn't mater if I put 0 or 999999999 as the x value in the position
parameter. The label is always in the same horizontal place.
Matplotlib version 2.0, Python 3.5 on Mac OSX El Capitan in Jupyter
notebook
Marplotlib installed via conda update matplotlib
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7946>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-IK1XxdjKJ7xRaKiu-V7Gf8I6umTks5rV30igaJpZM4LtuBc>
.
|
You're right, my apologies. Here's an example in pure matplotlib. The x position is still ignored. roberto = noms[noms.prenom == 'roberto'.upper()]
roberto = roberto.pivot_table('freq', index='annee', columns='sexe')
fig, ax = plt.subplots()
ax.title.set_text('Babies named Roberto')
ax.plot(roberto)
ax.axes.set_ylabel('BABIES', rotation=0, position=(2000,1.05)) |
Here is the full code to reproduce the problem: import matplotlib.pyplot as plt
import numpy as np
roberto = np.random.randint(0, 100, size=(10, ))
fig, ax = plt.subplots()
ax.title.set_text('Babies named Roberto')
ax.plot(roberto)
ax.set_ylabel('BABIES', rotation=0, position=(2000,1.05)) |
I have the same results on matplotlib 1.5 and matplotlib 2.0. |
I just upgraded to 2.0 via conda.
…On Thu, 26 Jan 2017, 00:57 Nelle Varoquaux, ***@***.***> wrote:
I have the same results on matplotlib 1.5 and matplotlib 2.0.
Which version of matplotlib are you using?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7946 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKZuZfdb8Q_dpmosNn2Oy-7i7n9HXsVks5rWDXQgaJpZM4LtuBc>
.
|
After a play around I've found that by setting I can't seem to be getting it working in 1.5.3 either, do you know what version you upgraded from? |
Oh, I put 2000 in there just to show that no matter what x value I set, it
didn't make a difference. I should have been clearer. I'm sorry, I don't
know what version I upgraded from.
|
Hmm, I'm not convinced setting It might be worth another dev having a look... In the meantime I'd recommend just adding a normal text box to the plot which should give you full control over position. |
Punting this to |
After a bit of a hunt, I think this is a duplicate of #7112 |
Closing as I am not sure this ever worked. |
Hi, is there any solution? I use the latest version of Matplotlib 3.2.1, but |
@Harrypotterrrr This would be a feature request at this point. We just did a similar dance for title (#17127), so its possible to allow manual placement, but its not implemented for |
I'm going to re-open as something that would be nice to support. Though, really, if you are going to specify x, y, then why not just use |
Marking as good first issue because someone could follow #17127 pretty easily.... |
@jklymak Thanks for your help! I have found a solution to this tricky but simple problem. |
There should not be an overlap problem. Perhaps you can share your code, maybe in a different issue. |
Hi, in my case I would like to manually align the ylabel of ax2 with the ylabel of ax1, without modifying the latter.
However, the
But in this case the x coordinate is junk.
|
The postion of the ylabel is not known until a draw is made so calling fig.canvas.draw() first is needed. |
BTW, I assume we are all aware of: https://matplotlib.org/gallery/pyplots/align_ylabels.html |
@jklymak I imagined there was a similar problem. Still, as a user it is frustrating not to have the getter method corresponding to the setter method, as well as it is frustrating to obtain a junk coordinate out of I am aware of |
I understand that label coordinates change dynamically, in particular upon changing the tick labels, I guess. But isn't it so also for other quantities? For example, the limits change according to the lines which are plotted. Still, at any time I can call |
Sure, because we trigger a recalc when users ask for the x/ylims. But every other possible thing that can get changed at draw time doesn't necessarily get a recalc just because no one has put the hooks in. However, in this case, you basically have to recalculate everything, so you may as well just do a full draw. I'm curious why you want to align with the closest label. That will presumably overwrite the tick labels on the axes you are moving the label on. |
I understand, thanks for the explanation. Well, it's because tick labels have different width, e.g. the label for the value -1 is very large compared to, say, the labels for 1,2,3, etc. In my case I only have one label with the minus sign which is pretty far from the axis label. So it is OK to have the label nominally overlapping the tick labels, since in practice it does not (they are physically far apart). Actually, it looks better to have it closer to the axis. For what concerns me, now I have understood how this works, and that is fine. So for example, compare:
with
It seems reasonable that the two snippets should do the same, but they do not. |
Sure, I agree - thats the suggested fix, is for someone to make the automatic label repositioning over-rideable with manual values if desired, like we did in #17127 for the title. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Uh oh!
There was an error while loading. Please reload this page.
Using matplotlib with Seaborn's FacetGrid. Before upgrade to 2.0, setting the x,y position of the y-axis label worked. Now only y-position is respected.
It doesn't mater if I put 0 or 999999999 as the x value in the
position
parameter. The label is always in the same horizontal place.Matplotlib version 2.0, Python 3.5 on Mac OSX El Capitan in Jupyter notebook
Matplotlib installed via
conda update matplotlib
The text was updated successfully, but these errors were encountered: