Colorbar interfering with figure

I have a application that plots figures on demand. I’m running into an issue when plotting more than one parameter on a figure. Each parameter is run through libraries that I’ve written that make decisions and eventually plots the figure. However, for some figures (when two parameters are plotted), the colorbar plots atop the main figure (see the attached).

I think the reason is that each time through the libraries, a separate basemap is created (although with the same values) but for the first parameter, a colorbar is plotted and for the second, there will never be a colorbar. So the final figure plots the colorbar on top.

is there a way to test the gca() to see if a basemap has been created, or to detect whether the gcs() has a colorbar and leave the map/figure alone. (I’m not exactly sure if it’s the re-creation of the basemap or the fact that the second parameter will not contain a colorbar that is the issue.)

Anyone crossed this bridge?

Bruce

Selection_083.png

···

Bruce W. Ford
Clear Science, Inc.

I have a application that plots figures on demand. I’m running into an issue when plotting more than one parameter on a figure. Each parameter is run through libraries that I’ve written that make decisions and eventually plots the figure. However, for some figures (when two parameters are plotted), the colorbar plots atop the main figure (see the attached).

I think the reason is that each time through the libraries, a separate basemap is created (although with the same values) but for the first parameter, a colorbar is plotted and for the second, there will never be a colorbar. So the final figure plots the colorbar on top.

is there a way to test the gca() to see if a basemap has been created, or to detect whether the gcs() has a colorbar and leave the map/figure alone. (I’m not exactly sure if it’s the re-creation of the basemap or the fact that the second parameter will not contain a colorbar that is the issue.)

Anyone crossed this bridge?

Bruce


Bruce W. Ford
Clear Science, Inc.

What is creating a colorbar? My usual coding style is such that any functions I make to do complicated plots do not do any more than is necessary. All axis limits, title setting and colorbar making are left for the caller of the plotting function.

From your description, it is hard to tell if the bug is in your code, basemap, or some other third-party library. Could you please clarify?

Cheers!
Ben Root

P.S. - Furthermore, I really like using the axes_grid1 toolkit because I can specify if I want space pre-allocated for colorbars. This way, when I create my colorbar, I can pass the pre-allocated axes object that was made just for the colorbar.

···

On Mon, Feb 13, 2012 at 10:38 AM, Bruce Ford <bruce@…3968…5…> wrote:

I have a application that plots figures on demand. I’m running into an issue when plotting more than one parameter on a figure. Each parameter is run through libraries that I’ve written that make decisions and eventually plots the figure. However, for some figures (when two parameters are plotted), the colorbar plots atop the main figure (see the attached).

I think the reason is that each time through the libraries, a separate basemap is created (although with the same values) but for the first parameter, a colorbar is plotted and for the second, there will never be a colorbar. So the final figure plots the colorbar on top.

is there a way to test the gca() to see if a basemap has been created, or to detect whether the gcs() has a colorbar and leave the map/figure alone. (I’m not exactly sure if it’s the re-creation of the basemap or the fact that the second parameter will not contain a colorbar that is the issue.)

Anyone crossed this bridge?

Bruce