def __axes_spmap(self): for x in xrange(self.nh): for y in xrange(self.nv): w = self.horizontal_subplot_size h = self.vertical_subplot_size l = 1.0 - self.right_margin - w * ( x + 1) + 0.5 * self.horizontal_space b = self.bottom_margin + self.ylabel_area + h * y + 0.5 * self.vertical_space axes = pl.axes( [l, b, w - self.horizontal_space, h - self.vertical_space]) axes.cla() if self.showaxislabel and y == 0 and x == self.nh - 1: casalog.post('label "{label}" unit "{unit}"'.format( label=self.spectral_label, unit=self.spectral_unit), priority='DEBUG') if self.spectral_unit is not None and len( self.spectral_unit) > 0: spectral_label = '%s [%s]' % (self.spectral_label, self.spectral_unit) else: spectral_label = self.spectral_label axes.xaxis.set_label_text(spectral_label, size=self.ticksize) if self.normalization_factor < 100 and self.normalization_factor > 0.01: label_text = 'Intensity [%s]' % self.brightnessunit else: label_text = 'Intensity [1e%d x %s]' % ( int(numpy.log10(self.normalization_factor)), self.brightnessunit) axes.yaxis.set_label_text(label_text, size=self.ticksize, rotation='vertical') if self.showtick: axes.xaxis.tick_bottom() axes.yaxis.tick_left() if self.showticklabel: xlocator = pl.AutoLocator() xlocator.set_params(nbins=6, prune='upper') axes.xaxis.set_major_locator(xlocator) ylocator = pl.AutoLocator() ylocator.set_params(nbins=4) axes.yaxis.set_major_locator(ylocator) xformatter = pl.ScalarFormatter(useOffset=False) axes.xaxis.set_major_formatter(xformatter) axes.xaxis.set_tick_params( labelsize=max(self.ticksize - 1, 1)) axes.yaxis.set_tick_params( labelsize=max(self.ticksize - 1, 1)) if y != 0 or x != self.nh - 1: axes.xaxis.set_major_formatter(pl.NullFormatter()) axes.yaxis.set_major_formatter(pl.NullFormatter()) else: axes.xaxis.set_major_formatter(pl.NullFormatter()) axes.yaxis.set_major_formatter(pl.NullFormatter()) else: axes.yaxis.set_major_locator(pl.NullLocator()) axes.xaxis.set_major_locator(pl.NullLocator()) yield axes
def locator(self): # {{{ '''Returns a matplotlib locator object for use in plotting.''' import pylab as pyl scl = self.plotatts.get('plotscale', 'linear') if scl == 'log': return pyl.LogLocator() else: return pyl.AutoLocator()
def plot_setticks(x=True, y=True): pl.minorticks_on() ax = pl.gca() if x: ax.xaxis.set_major_locator(pl.AutoLocator()) x_major = ax.xaxis.get_majorticklocs() dx_minor = (x_major[-1] - x_major[0]) / (len(x_major) - 1) / 5. ax.xaxis.set_minor_locator(pl.MultipleLocator(dx_minor)) else: pl.minorticks_off() if y: ax.yaxis.set_major_locator(pl.AutoLocator()) y_major = ax.yaxis.get_majorticklocs() dy_minor = (y_major[-1] - y_major[0]) / (len(y_major) - 1) / 5. ax.yaxis.set_minor_locator(pl.MultipleLocator(dy_minor)) else: pl.minorticks_off()