colorbar behavior

I would like to ask about the behavior of colorbar(). In my opinion, the
default colorbar is too big. I know the default is similar to matlab's
colorbar, but I dont think it should stretch beyond the axes. Also, there is
arguably too much space between the colorbar and the right edge of the
figure. I'm attaching two pngs, one is the default behavior and the other is
my suggested alternative, which I did with colorbar(fraction=0.0305). I don't
understand what fraction is scaled to. I expected fraction=1 to make the
height equal to the original axes height, but that actually crashes python:

terminate called after throwing an instance of 'std::bad_alloc'
  what(): St9bad_alloc
Aborted

I don't want to seem too critical of the work that has already been put into
the colorbar. I just think it needs a bit of polish. Comments?

Darren

default_colorbar.png

smaller_colorbar.png

Darren,

I don't like the default either--I just left it in place so as not to change too many things at once. There is always some tension in mpl between doing things the Matlab way, at least by default, and doing things better. If there is no opinion to the contrary, I am happy to change colorbar defaults for the better. I use the "shrink" kwarg routinely to make the colorbar smaller; I think it should be smaller by default. I generally prefer a colorbar with a length about 80% that of the corresponding image axis length.

What is really needed to optimize it, however, is a smarter axes packing algorithm. So far, I have considered it best to at least defer this potentially complex change in favor of sticking with simple automatic behavior and the present reasonably easy manual configurability. There may still be fairly simple ways to improve the default behavior, however, beyond picking better default parameters for the present algorithms.

The present algorithm divides the figure box in two, with "fraction" giving the fraction reserved for the colorbar. The image axes are then resized and repositioned within the remainder.

One of the reasons that doing a really good job of automatic colorbar sizing and positioning is not trivial is that aspect ratio handling in the draw method determines the actual size of the image; to make the colorbar match that, we would have to put the colorbar sizing in the draw method after the image dimensions have been determined. Probably this can all be done cleanly the same sort of Value magic that is used in transforms, but I have not tried to figure it out. I think it would require setting up some sort of axes drawing order, with care taken to avoid circular dependencies.

So, to summarize, I don't mind doing some simple things to make colorbar sizing usually look nicer by default, but a more complex and complete solution is not high priority for me now.

Eric

Darren Dale wrote:

···

I would like to ask about the behavior of colorbar(). In my opinion, the default colorbar is too big. I know the default is similar to matlab's colorbar, but I dont think it should stretch beyond the axes. Also, there is arguably too much space between the colorbar and the right edge of the figure. I'm attaching two pngs, one is the default behavior and the other is my suggested alternative, which I did with colorbar(fraction=0.0305). I don't understand what fraction is scaled to. I expected fraction=1 to make the height equal to the original axes height, but that actually crashes python:

terminate called after throwing an instance of 'std::bad_alloc'
  what(): St9bad_alloc
Aborted

I don't want to seem too critical of the work that has already been put into the colorbar. I just think it needs a bit of polish. Comments?

Darren

------------------------------------------------------------------------

------------------------------------------------------------------------

------------------------------------------------------------------------

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel