Hello,
In the 0.9.6 version, it does not appear to be possible to pass any arguments to the colorbar plotting
routine.
explicitly sets set_colorbar = False, which makes sense.
However, if we want horizontal colorbars, or any way of adjusting the colorbar plotted (it is huge and unwieldy), it would be good if the plotting routine checks for and passes suitable arguments to
https://github.com/pydata/xarray/blob/8267fdb1093bba3934a172cf71128470698279cd/xarray/plot/facetgrid.py#L256
I tried hacking something together, I can do something like the following now:
import xarray
import matplotlib.pyplot as plt
data = xarray.open_dataset('/data/ERSST/sst.mnmean.old.nc').sst
data = data.loc[dict(time=slice('1999-1', '1999-4'))]
data.plot.contourf(col='time', col_wrap=2, levels=12, cbar_kwargs=dict(orientation='horizontal',
pad=0.1, aspect=30, shrink=0.6, ticks=[0, 10, 20 ,30]))
which produces:

Is something like this available in the development version? If not, and it seems like a useful feature, I can create a PR.
Joy
I don't think we have anything like this in the development version yet.
I wonder if it would be better to stop plotting colorbars automatically, and instead require explicitly calling add_colorbar()?
What are the arguments against cbar_kwargs ? This would be consistent with the API of the other 2D plots
Indeed, for consistency it would make sense to add cbar_kwargs. I'm just thinking that going forward (if we can solve the backwards compatibility problem) it might be cleaner to avoid making a color-bar automatically in the same call to .plot().
it might be cleaner to avoid making a color-bar automatically in the same call to .plot()
For all 2D plots or just for facetgrids? In general I like the all-in-one feeling of xarray plots currently, and I imagine that the automatic colorbar is used very often.
I was thinking for everything. But I'm OK deferring to your judgment on
this one :)
On Mon, Nov 20, 2017 at 9:26 AM Fabien Maussion notifications@github.com
wrote:
it might be cleaner to avoid making a color-bar automatically in the same
call to .plot()For all 2D plots or just for facetgrids? In general I like the all-in-one
feeling of xarray plots currently, and I imagine that the automatic
colorbar is used very often.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/pydata/xarray/issues/1717#issuecomment-345767423, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABKS1o4i7stbLAdiYoeUgpe2QqEETQR5ks5s4bZXgaJpZM4QfQmj
.
Great, will prepare a PR! I second @fmaussion on keeping the auto colorbar, just makes life easy!
Most helpful comment
For all 2D plots or just for facetgrids? In general I like the all-in-one feeling of xarray plots currently, and I imagine that the automatic colorbar is used very often.