You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
y-axis label no longer obeys x position in 2.0 #7946
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.
importseabornassnsimportmatplotlib.pyplotaspltg= (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
Matplotlib installed via conda update matplotlib
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>
.
After a play around I've found that by setting position=(x,y), y is in figure co-ordinates, so y=0.5 puts the label halfway up the axis. Setting x=2000 (if it worked) would probably put the legend way off the the right of the figure.
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.
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.
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.
However, maybe it is good to get rid of some inconsistencies on the long run.
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!
Activity
WeatherGod commentedon Jan 25, 2017
robroc commentedon Jan 25, 2017
You're right, my apologies. Here's an example in pure matplotlib. The x position is still ignored.
NelleV commentedon Jan 26, 2017
Here is the full code to reproduce the problem:
NelleV commentedon Jan 26, 2017
I have the same results on matplotlib 1.5 and matplotlib 2.0.
Which version of matplotlib are you using?
robroc commentedon Jan 27, 2017
dstansby commentedon Feb 1, 2017
After a play around I've found that by setting
position=(x,y),yis in figure co-ordinates, soy=0.5puts the label halfway up the axis. Settingx=2000(if it worked) would probably put the legend way off the the right of the figure.I can't seem to be getting it working in 1.5.3 either, do you know what version you upgraded from?
robroc commentedon Feb 1, 2017
dstansby commentedon Feb 1, 2017
Hmm, I'm not convinced setting
xlocation of a y-label orylocation of an x-label ever worked. The relevant line which sets the label location I think is https://github.com/matplotlib/matplotlib/blame/master/lib/matplotlib/axis.py#L2161 which hasn't changed for at least 5 years.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.
dstansby commentedon Mar 18, 2017
Punting this to
2.1as no-one has disagreed (yet) with my assertion that this never worked.dstansby commentedon Mar 19, 2017
After a bit of a hunt, I think this is a duplicate of #7112
19 remaining items
fperonaci commentedon Oct 16, 2020
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.
However, maybe it is good to get rid of some inconsistencies on the long run.
So for example, compare:
with
It seems reasonable that the two snippets should do the same, but they do not.
jklymak commentedon Oct 16, 2020
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.
github-actions commentedon Jan 26, 2024
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!