On 12/27/2011 03:11 PM, Jeff Whitaker wrote: > On 12/27/11 12:07 PM, Logi Ragnarsson wrote: >> Hello, >> >> Is it supposed to be possible to do a filled contour plot with alpha >> levels in the colour map? I'm plotting weather data on top of maps and >> would very much like to plot low levels of wind and precipitation as >> mostly transparent, with higher levels more opaque. >> >> If I replace the meat of the plotting code with these two lines: >> >> basemap.bluemarble() >> basemap.contourf(x, y, precipitation, >> colors=colorConverter.to_rgba_array([ >> # no colour for zero -> fully transparent >> (1,0,0,0.5), >> (0,1,0,1), >> (0,1,1,0.5), >> (0,0,1,1), >> (1,0,1,0.5) >> ]), levels=[ >> # no level for zero -> fully transparent >> 0.001, >> 0.01, >> 0.1, >> 1, >> 10 >> ]) >> >> I end up with the (deliberately) pretty horrible looking plot in the >> attachment. The alpha values in the colors argument are completely >> ignored, but having no colour specified for values below 0.001 (mm/hr) >> causes those areas to be left transparent. I'm plotting the Blue >> Marble simply to have something visible under the weather plot. >> >> Is this supposed to work at all in any way? >> >> I'm using matplotlib 1.1.0 and basemap 1.0.2 on debian with the 'Agg' >> back-end. The data being plotted is a netCDF dataset read from the >> output of the WRF weather model. >> >> Regards, >> Logi >> > > Logi: It looks like alpha transparency is controlled with the alpha > keyword, so you can't specify different alphas for each contour level. > You may have to call contourf multiple times, changing the alpha as > needed for each set of contour levels.
It looks like this is something I can fix by modifying ListedColormap. It is discarding the alpha values, and I don't think there is any reason it needs to do so. Eric > > -Jeff > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users