WIP: Properly set pobj and don't make colorbar if this is None#219
WIP: Properly set pobj and don't make colorbar if this is None#219rjleveque wants to merge 1 commit intoclawpack:masterfrom
Conversation
|
I have been seeing something similar lately as well when playing with some methods for reducing the memory footprint when plotting 1,000s of patches (colorbar and axes are screwed up). I am not sure if these are related but I like the idea of moving towards removing |
|
This is a big enough job that I think we should leave it for the next release, and put a note in that plotting with Python3 may have some problems currently. |
|
Another way to do this that keeps some of the vmin = pp['pcolor_cmin']
if vmin is 'auto':
vmin = None
vmax = pp['pcolor_cmax']
if vmax is 'auto':
vmax = None
edgecolors = None
if pp['celledges_show']:
edgescolors = pp['celledges_color']
if not var_all_masked:
plot_cmd = getattr(plt.gca(), pc_cmd)
pobj = plot_cmd(X_edge, Y_edge, var, cmap=pp['pcolor_cmap'],
vmin=vmin, vmax=vmax, edgecolors=edgecolors,
**pp['kwargs'])This was an attempt at fixing the problem in clawpack/geoclaw#275 which did not work. |
|
I ran into something similar in Python 3 again. I changed assignment of |
|
Does this also work for making a colorbar when all patches are completely masked? This happens in what we're now testing with using the adjoint to flag for refinement and want to plot the flagged cells. At later times it may happen that no cells are flagged and all patches are masked. I suspect this has to be dealt with differently since it doesn't know the colormap to use in the colorbar if there's no pobj the colorbar goes with. |
I was seeing strange behavior in GeoClaw plots in Python3, that sometimes the colorbar showed up all green (from the land plots) rather than showing the colorbar for the ocean plot, even though that was the only one requested.
Also when plotting data that was entirely masked on all patches, the gauge was plotted where the colorbar should have been.
I figured out there was a problem in how
execwas used that meantpobjwasn't getting set at all. Moreoverexecandcolorbarboth work differently in Python3.I've rewritten the way
pobjis set when calling thepcolorfunction for this particularplot_type, to put all the arguments intokwargs(rather than constructing a stringpcolor_cmdand then usingexec).I suggest we might want to do the same for all other
plot_typesand I'll work on that unless anyone has a better idea how to do this.I also modified the code so that if
pobjends up asNone, meaning all patches were masked, then it does not make a colorbar. But then the main plot ends up bigger than it would otherwise, unpleasant in an animation with other frames. I think we might want to rewrite all the colorbar stuff to usecolorbar.make_axes_gridspecto always make the colorbar axes, and probably we should make it easier for the user to specify other attributes of colorbars (e.g. location, orientation).