[yt-users] customizing colorbar

sacielo sacielo at gmail.com
Sat Jul 8 01:48:20 PDT 2017


Hello,

I was trying to change the looks of the colorbar of slice plots; first I
found out I could create a new colorbar in a new position. I obtained
something I like very much like this (for some dataset ds):

​myvar = 'density'
sl = yt.SlicePlot(ds, 'x', myvar, center='c', width=(3,'kpc'))
sl.hide_colorbar()
sl.hide_axes()
plot   = sl.plots[myvar]
fig    = plot.figure
new_ax = fig.add_axes((0.025,0.94,0.75,0.025))
​​
cb     = plot.figure.colorbar(plot.image, new_ax, extend='both',
orientation='horizontal', format='%.0E'​)​
sl._setup_plots()

​The only problem now is I cannot change the font properties of this new
colorbar. Even trying​, e.g.:

sl.set_font({'family': 'sans-serif', 'style': 'normal', 'weight': 'normal',
'size': 36})

​will change all fonts, including the default colorbar, all text and
annotations, but not this new colorbar.
I think plot.figure.colorbar does not accept any argument to edit the font.

Do you know how I could change this? Or maybe have I gone down the wrong
path?
​I wouldn't like to do all manually with matplotlib, as I plan to add many
more yt annotations to this plot, which all work very well.

​Thank you!​

​Best,​

-- 
Salvatore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170708/ad1d41c4/attachment.htm>


More information about the yt-users mailing list