My historic Seaborn example doesn't seem to work anymore with Matplotlib-2.2.0rc1. is it a volontary change ?
# Seaborn# for more examples, see http://stanford.edu/~mwaskom/software/seaborn/examples/index.htmlimportseabornassnssns.set()
df=sns.load_dataset("iris")
sns.pairplot(df, hue="species", size=1.5)
Actual outcome
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-78e2f3db95aa> in <module>()
4 sns.set()
5 df = sns.load_dataset("iris")
----> 6 sns.pairplot(df, hue="species", size=1.5)
C:\WinPython\bd35\buildQt5\winpython-32bit-3.5.x.2\python-3.5.4\lib\site-packages\seaborn\axisgrid.py in pairplot(data, hue, hue_order, palette, vars, x_vars, y_vars, kind, diag_kind, markers, size, aspect, dropna, plot_kws, diag_kws, grid_kws)
2058 if grid.square_grid:
2059 if diag_kind == "hist":
-> 2060 grid.map_diag(plt.hist, **diag_kws)
2061 elif diag_kind == "kde":
2062 diag_kws["legend"] = False
C:\WinPython\bd35\buildQt5\winpython-32bit-3.5.x.2\python-3.5.4\lib\site-packages\seaborn\axisgrid.py in map_diag(self, func, **kwargs)
1333 diag_ax = ax._make_twin_axes(sharex=ax,
1334 sharey=diag_axes[0],
-> 1335 frameon=False)
1336 else:
1337 diag_ax = ax._make_twin_axes(sharex=ax, frameon=False)
C:\WinPython\bd35\buildQt5\winpython-32bit-3.5.x.2\python-3.5.4\lib\site-packages\matplotlib\axes\_subplots.py in _make_twin_axes(self, *kl, **kwargs)
174 from matplotlib.projections import process_projection_requirements
175 if 'sharex' in kwargs and 'sharey' in kwargs:
--> 176 raise ValueError("Twinned Axes may share only one axis.")
177 kl = (self.get_subplotspec(),) + kl
178 projection_class, kwargs, key = process_projection_requirements(
ValueError: Twinned Axes may share only one axis.
The change in _make_twin_axes was deliberate. Under what circumstances does it make sense to share both axes with twin axes? The point of twin axes is to share one axis and have the other one differ.
The change in _make_twin_axes was deliberate. Under what circumstances does it make sense to share both axes with twin axes? The point of twin axes is to share one axis and have the other one differ.
seaborn shouldn't have been using a private method here, but if the issue is just redundancy, is there any reason matplotlib needs to raise on getting sharex and sharey when one of the shared axes is self?
Speaking as a matplotlib dev with no attachment to the APIs in question, I'm sensitive to the idea that we not break one of the more prominent downstream libraries. So I'm ok with getting in a change to avoid this breakage before we cut 2.2.
I'm also pretty damned irritated that we have to work around this prominent library using an internal API; especially since it seems that this downstream library has made no effort whatsoever in getting a public version of this API. (Please correct me if I'm wrong on this.) So I'm also tempted to say that unless a seaborn dev is willing to put some skin in the game and propose a PR to get a public API that serves their purpose, we don't do a thing. THIS is literally the reason that as a developer of another project, YOU DON'T USE SOMEONE ELSE'S INTERNAL APIS.
OK, fair enough - tracing through all the twin code is difficult. I did reopen and remilestone so this will at least get discussion before 2.2 drops.
I'm still not clear why you want twin axes versus just clearing the diagonal axes and resetting the share properties. But no doubt I'm not following exactly what PairGrid etc are doing.
if'sharex'inkwargsand'sharey'inkwargs:
raiseValueError("Twinned Axes may share only one axis.")
to
if'sharex'inkwargsand'sharey'inkwargs:
ifkwargs["sharex"] isnotselfandkwargs["sharey"] isnotself:
raiseValueError("Twinned Axes may share only one axis.")
We can also have a conversation about a public API for twinned, shared axes (which I've proposed above), but that shouldn't be a blocker for 2.2. And, as noted, fixing this error check would be a precondition for making that possible.
@mwaskom is it not possible write (or just copy the old code in _make_twin_axes) a method to do what you want to do instead of relying on our private one, and then putting out a patch release of seaborn with that fix?
Activity
stonebig commented on Feb 24, 2018
so it comes from this change:
#10033
how should we rewrite an old code like :
is it ?:
tacaswell commented on Feb 24, 2018
attn @efiring
I think was was intentional to account for interactions between twin, shared axes, and fixed aspect ratio.
stonebig commented on Feb 24, 2018
ok, I patched seaborn for my need. seaborn maintainer ask if this internal breakage could be avoided:
mwaskom/seaborn#1378 (comment)
jklymak commented on Feb 24, 2018
Can you distill to a non-seaborn example? I’m still not sure what seaborn is trying to do that breaks, but I haven’t read the source.
stonebig commented on Feb 24, 2018
Similar examples would come from holoviews (replace 'bokeh' per 'matplotlib'):
stonebig commented on Feb 24, 2018
more similar would be with hv.Histogram, yet more verbose than compact seaborn
from bokeh.sampledata.iris import flowers from holoviews.operation import gridmatrix ds = hv.Dataset(flowers) grouped_by_species = ds.groupby('species', container_type=hv.NdOverlay) grid = gridmatrix(grouped_by_species, diagonal_type=hv.Histogram)jklymak commented on Feb 24, 2018
I meant can you trigger the error using matplotlib only?
stonebig commented on Feb 24, 2018
hum, it's not an internal error of Matplotlib-2.2.0rc1, if that is your question.
jklymak commented on Feb 24, 2018
So I'm confused; is this a matplotlib problem (i.e. something that worked pre #10033)? If so, then it must be triggerable with just matplotlib calls.
stonebig commented on Feb 25, 2018
seaborn was using an "internal API", functions starting per the undescore characters:
efiring commented on Feb 25, 2018
The change in _make_twin_axes was deliberate. Under what circumstances does it make sense to share both axes with twin axes? The point of twin axes is to share one axis and have the other one differ.
stonebig commented on Feb 25, 2018
ok. I agree it was probably a functional bug of seaborn.
mwaskom commented on Feb 27, 2018
@efiring
seaborn shouldn't have been using a private method here, but if the issue is just redundancy, is there any reason matplotlib needs to raise on getting sharex and sharey when one of the shared axes is self?
15 remaining items
dopplershift commented on Feb 27, 2018
Speaking as a matplotlib dev with no attachment to the APIs in question, I'm sensitive to the idea that we not break one of the more prominent downstream libraries. So I'm ok with getting in a change to avoid this breakage before we cut 2.2.
I'm also pretty damned irritated that we have to work around this prominent library using an internal API; especially since it seems that this downstream library has made no effort whatsoever in getting a public version of this API. (Please correct me if I'm wrong on this.) So I'm also tempted to say that unless a seaborn dev is willing to put some skin in the game and propose a PR to get a public API that serves their purpose, we don't do a thing. THIS is literally the reason that as a developer of another project, YOU DON'T USE SOMEONE ELSE'S INTERNAL APIS.
jklymak commented on Feb 27, 2018
OK, fair enough - tracing through all the twin code is difficult. I did reopen and remilestone so this will at least get discussion before 2.2 drops.
EDIT: Ooops, crossing comments....
mwaskom commented on Feb 27, 2018
Thanks @dopplershift for the constructive contributions.
mwaskom commented on Feb 27, 2018
My proposal is literally to change
to
mwaskom commented on Feb 27, 2018
We can also have a conversation about a public API for twinned, shared axes (which I've proposed above), but that shouldn't be a blocker for 2.2. And, as noted, fixing this error check would be a precondition for making that possible.
make seaborn great again on Matplotlib-2.2
dstansby commented on Feb 27, 2018
@mwaskom is it not possible write (or just copy the old code in _make_twin_axes) a method to do what you want to do instead of relying on our private one, and then putting out a patch release of seaborn with that fix?
mwaskom commented on Feb 27, 2018
No.
dstansby commented on Feb 27, 2018
Why not?
dopplershift commented on Feb 28, 2018
That doesn't solve the problem of all the existing installs being broken.
jklymak commented on Feb 28, 2018
Note that @lkjell took a crack at adding share/unshare in #9923. I think that is what would be useful for the seaborn use case...
jklymak commented on Feb 28, 2018
Closed #10622
make seaborn great again on Matplotlib-2.2