colorbar position

Hi,
just a small wish for the new colorbar; I think it by default may be
positioned a bit too close to the figure,
see examples below. (plotted by this sequence with yesterdays svn checkout)

... load data
axis('image')
axis([0,IM,0,JM])
C = contourf(x,y,H,levels)
colorbar(C)
hsv()
xlabel('X')
ylabel('Y')
grid(linestyle=':')

part of the reason is that I normally use long, outward pointing ticks,
so an extra argument to colorbar to in some way adjust the position
relative to the figure would be useful. Otherwise the new colorbar
works very well!

thanks,
Helge

axis_normal.png

axis_image.png

axis_equal.png

Helge,

This is actually a bug in the colorbar positioning that shows up when it is put next to a narrow plot. I will take another look at the positioning logic. Thanks for the report.

Eric

Helge Avlesen wrote:

···

Hi,
just a small wish for the new colorbar; I think it by default may be
positioned a bit too close to the figure,
see examples below. (plotted by this sequence with yesterdays svn checkout)

Helge,

I have committed some changes to the colorbar positioning code that I think fix the bug you found--which was actually a difference between the way positioning worked in interactive mode versus in a script--and generally improved it. There is a new kwarg, 'pad', to control the spacing. It is a fraction of the original parent axes. Defaults are 0.05 for vertical axes and 0.15 for horizontal; in the latter case, it has to leave room for axis tick labels and the x-axis title. I think you will find the defaults tolerable.

The automatic repositioning is crude; it is suitable for interactive use, but for production plots people will often need to explicitly size and position the primary axes and the colorbar axes. It can probably be improved with a few tweaks here and there, but to do a much better job automatically would require major changes, and I don't think this should be a high priority. On the other hand, it is possible that redesigning positioning and aspect-ratio handling to take full advantage of all the wizardry in the transforms code would be a big step forward--but probably not an easy one. I am not going to try it right now.

Thanks again for the clear bug report.

Eric

Helge Avlesen wrote:

···

Hi,
just a small wish for the new colorbar; I think it by default may be
positioned a bit too close to the figure,
see examples below. (plotted by this sequence with yesterdays svn checkout)