tight_layout and ImageGrid

Hi,

I wrote a short routine to look through a set of images that result from
slightly different processing of the same data. I want to compare three
different images and be able to zoom them all in the same way and then
move onto the next set of three. The best way that I've found to do
that so far involves using mpl_toolkits.axes_grid1.ImageGrid. It all
works fine. I found that to get the most image on screen at once, using
the tight_layout=True argument to plt.figure gives excellent results.
My one question is that I get the following warning:

WARNING: This figure includes Axes that are not compatible with
tight_layout, so its results might be incorrect. [matplotlib.figure]

As I say, the results are good, so it's not really a problem, but I do
wonder about the source of the warngin -- and whether re-using the code
in a different way in the future could lead to problems. So, my
question is: what is the problem pointed to by the warning and how could
I avoid it (while still getting the same good results)?

Regards,
Jon

···

--
______________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin@...1081... 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
______________________________________________________________

ImageGrid creates axes for colobar even if cbar_mode=None. These axes for colorbar are set to invisible, so usually they are harmless.
tight_layout, however, do not care whether the axes is visible or not, and the warning is because of these “invisible” axes for colorbars.

For comparison, if you turn on all colorbar with cbar_mode=“each”, the warning will go away.

You may manually remove colorbar axes from the figure if you want,


for ax in grid.cbar_axes: fig._axstack.remove(ax)

but do this only when cbar_mode=None.

So, I think the warning is harmless.

I will make a pull request that make tight_layout to ignore any invisible axes soon.

Regards,

-JJ

···

On Wed, May 8, 2013 at 10:21 PM, Jonathan Slavin <jslavin@…1081…> wrote:

Hi,

I wrote a short routine to look through a set of images that result from

slightly different processing of the same data. I want to compare three

different images and be able to zoom them all in the same way and then

move onto the next set of three. The best way that I’ve found to do

that so far involves using mpl_toolkits.axes_grid1.ImageGrid. It all

works fine. I found that to get the most image on screen at once, using

the tight_layout=True argument to plt.figure gives excellent results.

My one question is that I get the following warning:

WARNING: This figure includes Axes that are not compatible with

tight_layout, so its results might be incorrect. [matplotlib.figure]

As I say, the results are good, so it’s not really a problem, but I do

wonder about the source of the warngin – and whether re-using the code

in a different way in the future could lead to problems. So, my

question is: what is the problem pointed to by the warning and how could

I avoid it (while still getting the same good results)?

Regards,

Jon


Jonathan D. Slavin Harvard-Smithsonian CfA

jslavin@…1081… 60 Garden Street, MS 83

phone: (617) 496-7981 Cambridge, MA 02138-1516

cell: (781) 363-0035 USA



Learn Graph Databases - Download FREE O’Reilly Book

“Graph Databases” is the definitive new guide to graph databases and

their applications. This 200-page book is written by three acclaimed

leaders in the field. The early access version is available now.

Download your free book today! http://p.sf.net/sfu/neotech_d2d_may


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users