def add_background(fig=None): """Add a linear background to the figure""" if fig is None: fig = P.gcf() colorb = cfgget('bgcolor_bottom') colort = cfgget('bgcolor_top') cmap = cmap_srs([colorb, colort]) bgaxes = fig.add_axes([0, 0, 1, 1]) bgaxes.set_axis_off() bgaxes.imshow([[0, 0], [1, 1]], origin='lower', interpolation='bilinear', cmap=cmap, aspect='auto', vmin=0, vmax=1)
# Inits from vacumm.misc.grid.masking import Lakes from vacumm.misc.grid.misc import meshbounds import vacumm.misc.color as C from vacumm.misc.plot import savefigs import numpy as N, pylab as P P.figure(figsize=(5.5, 5)) P.subplots_adjust(bottom=0.02, top=0.92, left=0.01, right=0.98, hspace=0.3) cmap_mask = C.cmap_linear(((0.6, 0.8, 1), C.land)) cmap_lakes = C.cmap_srs(("w", "r", "g", "b"), stretch=0) # Creer un mask avec des lacs mask = N.ones((20, 30), "?") # Terre partout mask[10:, 10:] = False # Ocean mask[10:15, 13:14] = True # Ocean mask[0, 0] = False # Ptit lac mask[5:15, 2:4] = False # Gros lac xxb, yyb = meshbounds(N.arange(mask.shape[1] * 1.0), N.arange(mask.shape[0] * 1.0)) xlim = (xxb.min(), xxb.max()) ylim = (yyb.min(), yyb.max()) P.subplot(221) P.pcolor(xxb, yyb, mask.astype("i"), cmap=cmap_mask) P.xlim(xlim) P.ylim(ylim) P.xticks([]) P.yticks([]) P.title("Mask initial") # Identification des lacs lakes = Lakes(mask)