def set_data(self, data): if data is None: self.inputdata = None self.chartdata = None return data = array(data) dim = len(shape(data)) if dim not in (1, 2, 3): raise AttributeError, "Input data must be a 1, 2, or 3d matrix" self.inputdata = data # If the input data is a 1d matrix, then it describes a # standard bar chart. if dim == 1: self.chartdata = array([[data]]) # If the input data is a 2d matrix, then it describes a bar # chart with groups. The matrix being an array of groups of # bars. if dim == 2: self.chartdata = transpose([data], axes=(2, 0, 1)) # If the input data is a 3d matrix, then it describes an array # of groups of bars with each bar being an array of stacked # values. if dim == 3: self.chartdata = transpose(data, axes=(1, 2, 0))
def _outline(self, X, Y): """ Return x, y arrays of colorbar bounding polygon, taking orientation into account. """ N = nx.shape(X)[0] ii = [0, 1, N - 2, N - 1, 2 * N - 1, 2 * N - 2, N + 1, N, 0] x = nx.take(nx.ravel(nx.transpose(X)), ii) y = nx.take(nx.ravel(nx.transpose(Y)), ii) if self.orientation == "horizontal": return y, x return x, y
def _outline(self, X, Y): ''' Return x, y arrays of colorbar bounding polygon, taking orientation into account. ''' N = nx.shape(X)[0] ii = [0, 1, N - 2, N - 1, 2 * N - 1, 2 * N - 2, N + 1, N, 0] x = nx.take(nx.ravel(nx.transpose(X)), ii) y = nx.take(nx.ravel(nx.transpose(Y)), ii) if self.orientation == 'horizontal': return y, x return x, y
def _add_solids(self, X, Y, C): """ Draw the colors using pcolormesh; optionally add separators. """ if self.orientation == "vertical": args = (X, Y, C) else: args = (nx.transpose(Y), nx.transpose(X), nx.transpose(C)) kw = {"cmap": self.cmap, "norm": self.norm, "shading": "flat"} col = self.ax.pcolor(*args, **kw) self.add_observer(col) self.solids = col if self.drawedges: self.dividers = LineCollection( self._edges(X, Y), colors=(rcParams["axes.edgecolor"],), linewidths=(0.5 * rcParams["axes.linewidth"],) ) self.ax.add_collection(self.dividers)
def _add_solids(self, X, Y, C): ''' Draw the colors using pcolormesh; optionally add separators. ''' if self.orientation == 'vertical': args = (X, Y, C) else: args = (nx.transpose(Y), nx.transpose(X), nx.transpose(C)) kw = {'cmap': self.cmap, 'norm': self.norm, 'shading': 'flat'} col = self.ax.pcolor(*args, **kw) self.add_observer(col) self.solids = col if self.drawedges: self.dividers = LineCollection( self._edges(X, Y), colors=(rcParams['axes.edgecolor'], ), linewidths=(0.5 * rcParams['axes.linewidth'], )) self.ax.add_collection(self.dividers)
def init_plot_data(self): # jdh you can add a subplot directly from the fig rather than # the fig manager a = self.fig.add_subplot(111) self.x = numerix.arange(120.0) * 2 * numerix.pi / 120.0 self.x.resize((100, 120)) self.y = numerix.arange(100.0) * 2 * numerix.pi / 100.0 self.y.resize((120, 100)) self.y = numerix.transpose(self.y) z = numerix.sin(self.x) + numerix.cos(self.y) self.im = a.imshow(z, cmap=cm.jet) #, interpolation='nearest')
def init_plot_data(self): # jdh you can add a subplot directly from the fig rather than # the fig manager a = self.fig.add_subplot(111) self.x = numerix.arange(120.0)*2*numerix.pi/120.0 self.x.resize((100,120)) self.y = numerix.arange(100.0)*2*numerix.pi/100.0 self.y.resize((120,100)) self.y = numerix.transpose(self.y) z = numerix.sin(self.x) + numerix.cos(self.y) self.im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest')
def set_err(self, err): if err is None: self.inputerr = None self.charterr = None return err = array(err) dim = len(shape(err)) if dim not in (1, 2, 3): raise AttributeError, "Input err must be a 1, 2, or 3d matrix" self.inputerr = err if dim == 1: self.charterr = array([[err]]) if dim == 2: self.charterr = transpose([err], axes=(2, 0, 1)) if dim == 3: self.charterr = transpose(err, axes=(1, 2, 0))
def init_plot_data(self): # jdh you can add a subplot directly from the fig rather than # the fig manager a = self.fig.add_axes([0.075,0.1,0.75,0.85]) cax = self.fig.add_axes([0.85,0.1,0.075,0.85]) self.x = numerix.arange(120.0)*2*numerix.pi/120.0 self.x.resize((100,120)) self.y = numerix.arange(100.0)*2*numerix.pi/100.0 self.y.resize((120,100)) self.y = numerix.transpose(self.y) z = numerix.sin(self.x) + numerix.cos(self.y) self.im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest') self.fig.colorbar(self.im,cax=cax,orientation='vertical')
def init_plot_data(self): # jdh you can add a subplot directly from the fig rather than # the fig manager a = self.fig.add_axes([0.075, 0.1, 0.75, 0.85]) cax = self.fig.add_axes([0.85, 0.1, 0.075, 0.85]) self.x = numerix.arange(120.0) * 2 * numerix.pi / 120.0 self.x.resize((100, 120)) self.y = numerix.arange(100.0) * 2 * numerix.pi / 100.0 self.y.resize((120, 100)) self.y = numerix.transpose(self.y) z = numerix.sin(self.x) + numerix.cos(self.y) self.im = a.imshow(z, cmap=cm.jet) #, interpolation='nearest') self.fig.colorbar(self.im, cax=cax, orientation='vertical')
def func(x): return transpose(fliplr(x))