Placing the Colorbar on top of a yt.Sliceplot plot but labeling and ticks are still right aligned

Hello yt-users I am trying to place the Colorbar of a yt.Sliceplot on the top of the image. I was looking at yt examples (under "a few complex plots") and the use of AxesGrid objects. Below is what I used, fig = plt.figure() grid = AxesGrid(fig, 111, nrows_ncols = (1, 1), axes_pad = 1.0, label_mode = "L", share_all = True, cbar_location="top", cbar_mode="single", cbar_size="10%", cbar_pad="2%", ) slc = yt.SlicePlot(ds,'z','density') plot = slc.plots['density'] plot.figure = fig plot.axes = grid[0].axes plot.cax = grid.cbar_axes[0] slc._setup_plots() plt.savefig('testing.png') The Colorbar is placed at the top but the labeling and ticks (of the Colorbar) are still aligned to the right of the Colorbar (as apposed to below the Colorbar). Is there something I'm missing or is there a simpler way to do this? Thank you in advance, Alberto

Hi Alberto, I'm disappointed to say that it seems that to do this, you'll need to access the fixed resolution buffer directly, which you can find examples of on that website. What I *think* needs to happen is for the Colorbar instantiation (which happens in base_plot_types.py around line 266 in current yt master) needs to have the orientation kwarg passed in. From what I can tell, it can't be changed afterward. I may be wrong about this, but I can't see how one might change the colorbar orientation in matplotlib after the fact. One possible way around this would be to pass through some orientation arguments, but I suspect that this will not be as straightforward as using the fixed resolution buffer directly. On Fri, Mar 13, 2020 at 1:27 PM <bayern50@gmail.com> wrote:
Hello yt-users
I am trying to place the Colorbar of a yt.Sliceplot on the top of the image. I was looking at yt examples (under "a few complex plots") and the use of AxesGrid objects. Below is what I used,
fig = plt.figure() grid = AxesGrid(fig, 111, nrows_ncols = (1, 1), axes_pad = 1.0, label_mode = "L", share_all = True, cbar_location="top", cbar_mode="single", cbar_size="10%", cbar_pad="2%", ) slc = yt.SlicePlot(ds,'z','density') plot = slc.plots['density'] plot.figure = fig plot.axes = grid[0].axes plot.cax = grid.cbar_axes[0] slc._setup_plots() plt.savefig('testing.png')
The Colorbar is placed at the top but the labeling and ticks (of the Colorbar) are still aligned to the right of the Colorbar (as apposed to below the Colorbar). Is there something I'm missing or is there a simpler way to do this?
Thank you in advance,
Alberto _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (2)
-
bayern50@gmail.com
-
Matthew Turk