コード例 #1
0
    def __create_axes3d(self, *args, **kwargs):
        """
        Create an axes.
        
        :param position: (*list*) Optional, axes position specified by *position=* [left, bottom, width
            height] in normalized (0, 1) units. Default is [0.13, 0.11, 0.775, 0.815].
        :param outerposition: (*list*) Optional, axes size and location, including labels and margin.
        
        :returns: The axes.
        """
        if len(args) > 0:
            position = args[0]
        else:
            position = kwargs.pop('position', None)
        outerposition = kwargs.pop('outerposition', None)
        ax = Axes3D(**kwargs)
        if position is None:
            position = [0.13, 0.11, 0.71, 0.815]
            ax.active_outerposition(True)
        else:
            ax.active_outerposition(False)
        ax.set_position(position)
        if not outerposition is None:
            ax.set_outerposition(outerposition)
            ax.active_outerposition(True)

        return ax
コード例 #2
0
    def new_axes(self, *args, **kwargs):
        '''
        Add an axes to the figure.
    
        :param position: (*list*) Optional, axes position specified by *position=* [left, bottom, width
            height] in normalized (0, 1) units. Default is [0.13, 0.11, 0.775, 0.815].
        :param outerposition: (*list*) Optional, axes size and location, including labels and margin.
        :param aspect: (*string*) ['equal' | 'auto'] or a number. If a number the ratio of x-unit/y-unit in screen-space.
            Default is 'auto'.
        :param bgcolor: (*Color*) Optional, axes background color.
        :param axis: (*boolean*) Optional, set all axis visible or not. Default is ``True`` .
        :param bottomaxis: (*boolean*) Optional, set bottom axis visible or not. Default is ``True`` .
        :param leftaxis: (*boolean*) Optional, set left axis visible or not. Default is ``True`` .
        :param topaxis: (*boolean*) Optional, set top axis visible or not. Default is ``True`` .
        :param rightaxis: (*boolean*) Optional, set right axis visible or not. Default is ``True`` .
        :param xaxistype: (*string*) Optional, set x axis type as 'normal', 'lon', 'lat' or 'time'.
        :param xreverse: (*boolean*) Optional, set x axis reverse or not. Default is ``False`` .
        :param yreverse: (*boolean*) Optional, set yaxis reverse or not. Default is ``False`` .
        
        :returns: The axes.
        '''
        axestype = kwargs.pop('axestype', 'cartesian')
        polar = kwargs.pop('polar', False)
        if polar:
            axestype = 'polar'
         
        kwargs['figure'] = self
         
        if axestype == 'polar':
            ax = PolarAxes(*args, **kwargs)
            #self.__set_axes(ax, **kwargs)
        elif axestype == 'map':
            ax = MapAxes(*args, **kwargs)
            #self.__set_axesm(ax, **kwargs)
        elif axestype == '3d':
            ax = Axes3D(*args, **kwargs)
            #self.__set_axes3d(ax, **kwargs)
        else:
            ax = Axes(*args, **kwargs)
            #self.__set_axes(ax, **kwargs)
        #self.__set_axes_common(ax, *args, **kwargs)   

        return ax
コード例 #3
0
    def subplots(self, nrows=1, ncols=1, position=None, sharex=False, sharey=False, \
        wspace=None, hspace=None, axestype='Axes', **kwargs):
        '''
        Create a figure and a set of subplots.

        :param nrows: (*int*) Number of rows.
        :param ncols: (*int*) Number of cols.
        :param position: (*list*) All axes' position specified by *position=* [left, bottom, width
            height] in normalized (0, 1) units. Default is [0,0,1,1].
        :param sharex: (*boolean*) If share x axis.
        :param sharey: (*boolean*) If share y axis.
        :param subplot_kw: (*dict*) Subplot key words.
        :param wspace: (*float*) The amount of width reserved for blank space between subplots,
            expressed as a fraction of the average axis width.
        :param hspace: (*float*) The amount of height reserved for blank space between subplots,
            expressed as a fraction of the average axis height.
        :param axestype: (*string*) Axes type [Axes | Axes3D | MapAxes | PolarAxes].

        :returns: The figure and the axes tuple.
        '''
        if position is None:
            if wspace is None and hspace is None:
                position = [0, 0, 1, 1]
            else:
                position = [0.13, 0.11, 0.775, 0.815]
        left = float(position[0])
        bottom = float(position[1])
        width = float(position[2])
        height = float(position[3])

        chart = self.getChart()
        chart.setRowNum(nrows)
        chart.setColumnNum(ncols)
        axs = []
        ax2d = nrows > 1 and ncols > 1
        w = width / ncols
        h = height / nrows
        iswspace = False
        ishspace = False
        if not wspace is None and ncols > 1:
            w = (width - wspace * (ncols - 1)) / ncols
            iswspace = True
        if not hspace is None and nrows > 1:
            h = (height - hspace * (nrows - 1)) / nrows
            ishspace = True
        axestype = axestype.lower()
        y = bottom + height - h
        for i in range(nrows):
            if ax2d:
                axs2d = []
            x = left
            if ishspace:
                if i > 0:
                    y -= hspace
            for j in range(ncols):
                if axestype == 'axes3d':
                    ax = Axes3D()
                    self.__set_axes3d(ax, **kwarg)
                elif axestype == 'mapaxes':
                    ax = MapAxes()
                    self.__set_axesm(ax, **kwargs)
                elif axestype == 'polaraxes':
                    ax = PolarAxes()
                else:
                    ax = Axes()
                    self.__set_axes(ax, **kwargs)
                ax.axes.isSubPlot = True
                if not iswspace and not ishspace:
                    x = left + w * j
                    y = (bottom + height) - h * (i + 1)
                    ax.set_position([x, y, w, h])
                    ax.set_outerposition([x, y, w, h])
                    ax.active_outerposition(True)
                else:
                    if iswspace:
                        if j > 0:
                            x += wspace
                    ax.set_position([x, y, w, h])
                    ax.active_outerposition(False)
                    x += w
                if sharex:
                    if i < nrows - 1:
                        ax.axes.getAxis(
                            Location.BOTTOM).setDrawTickLabel(False)
                if sharey:
                    if j > 0:
                        ax.axes.getAxis(Location.LEFT).setDrawTickLabel(False)
                chart.addPlot(ax.axes)
                if ax2d:
                    axs2d.append(ax)
                else:
                    axs.append(ax)
            if ax2d:
                axs.append(tuple(axs2d))
            y -= h

        chart.setCurrentPlot(0)
        return tuple(axs)