示例#1
0
    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))
示例#2
0
文件: barchart.py 项目: AMDmi3/gem5
    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))
示例#3
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
示例#4
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
示例#5
0
 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)
示例#6
0
 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)
示例#7
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_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')
示例#8
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_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')
示例#9
0
    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))
示例#10
0
文件: barchart.py 项目: AMDmi3/gem5
    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))
示例#11
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')
示例#12
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')
示例#13
0
 def func(x):
     return transpose(fliplr(x))
示例#14
0
 def func(x):
     return transpose(fliplr(x))