示例#1
0
    def __init__(self,
                 vars,
                 title=None,
                 limits={},
                 cmap=None,
                 colorbar='vertical',
                 axes=None,
                 figaspect='auto',
                 **kwlimits):
        """
        Creates a `Matplotlib2DGridViewer`.

        :Parameters:
          vars
            A `CellVariable` object.
          title
            displayed at the top of the `Viewer` window
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          cmap
            The colormap. Defaults to `matplotlib.cm.jet`
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          colorbar
            plot a colorbar in specified orientation if not `None`
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            cmap=cmap,
                                            colorbar=colorbar,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)

        xmin, ymin = self.vars[0].mesh.extents['min']
        xmax, ymax = self.vars[0].mesh.extents['max']

        self.image = self.axes.imshow(self._data,
                                      extent=(xmin, xmax, ymin, ymax),
                                      vmin=0,
                                      vmax=1,
                                      cmap=self.cmap)

        self.axes.set_xlim(xmin=self._getLimit('xmin'),
                           xmax=self._getLimit('xmax'))

        self.axes.set_ylim(ymin=self._getLimit('ymin'),
                           ymax=self._getLimit('ymax'))

        if title is None:
            self.axes.set_title(self.vars[0].name)
 def __init__(self, vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits):
     """Creates a `Matplotlib2DViewer`.
     
     :Parameters:
       vars
         a `CellVariable` object.
       title
         displayed at the top of the `Viewer` window
       limits : dict
         a (deprecated) alternative to limit keyword arguments
       xmin, xmax, ymin, ymax, datamin, datamax
         displayed range of data. Any limit set to 
         a (default) value of `None` will autoscale.
       cmap
         the colormap. Defaults to `matplotlib.cm.jet`
       colorbar
         plot a colorbar in specified orientation if not `None`
       axes
         if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
       figaspect
         desired aspect ratio of figure. If arg is a number, use that aspect
         ratio. If arg is 'auto', the aspect ratio will be determined from
         the Variable's mesh.
     """
     kwlimits.update(limits)
     AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title, 
                                         cmap=cmap, colorbar=colorbar, axes=axes, figaspect=figaspect,
                                         **kwlimits)
     
     self._plot()
示例#3
0
    def __init__(self, vars, title=None, scale=None, sparsity=None, log=False, limits={}, axes=None, figaspect='auto', **kwlimits):
        """Creates a `Matplotlib2DViewer`.

        :Parameters:
          vars
            a rank-1 `CellVariable` or `FaceVariable` object.
          title
            displayed at the top of the `Viewer` window
          scale
            if not `None`, scale all arrow lengths by this value
          sparsity
            if not `None`, then this number of arrows will be
            randomly chosen (weighted by the cell volume or face area)
          log
            if `True`, arrow length goes at the base-10 logarithm of the magnitude
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to 
            a (default) value of `None` will autoscale.
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title, axes=axes, figaspect=figaspect, **kwlimits)

        self.quiver(sparsity=sparsity, scale=scale)
        self.log = log
        
        self._plot()
    def __init__(self, vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits):
        """Creates a `Matplotlib2DViewer`.

        :Parameters:
          vars
            a `CellVariable` object.
          title
            displayed at the top of the `Viewer` window
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          cmap
            the colormap. Defaults to `matplotlib.cm.jet`
          colorbar
            plot a colorbar in specified orientation if not `None`
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title,
                                            cmap=cmap, colorbar=colorbar, axes=axes, figaspect=figaspect,
                                            **kwlimits)

        self._plot()
    def __init__(self,
                 vars,
                 title=None,
                 limits={},
                 cmap=None,
                 colorbar='vertical',
                 axes=None,
                 number=10,
                 levels=None,
                 figaspect='auto',
                 **kwlimits):
        """Creates a `Matplotlib2DContourViewer`.
        
        :Parameters:
          vars
            a `CellVariable` object.
          title
            displayed at the top of the `Viewer` window
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to 
            a (default) value of `None` will autoscale.
          cmap
            the colormap. Defaults to `matplotlib.cm.jet`
          colorbar
            plot a colorbar in specified orientation if not `None`
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          number
            contour `number` automatically-chosen levels
          *levels* [level0, level1, ..., leveln]
            A list of floating point numbers indicating the level
            curves to draw; eg to draw just the zero contour pass
            ``levels=[0]``
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.

        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            cmap=cmap,
                                            colorbar=colorbar,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)
        self.number = number
        self.levels = levels

        self._plot()
示例#6
0
    def __init__(self,
                 vars,
                 title=None,
                 limits={},
                 cmap=None,
                 colorbar='vertical',
                 axes=None,
                 figaspect='auto',
                 **kwlimits):
        """Creates a `Matplotlib2DGridViewer`.

        Parameters
        ----------
        vars : ~fipy.variables.cellVariable.CellVariable
            the `Variable` to display.
        title : str, optional
            displayed at the top of the `Viewer` window
        limits : dict, optional
            a (deprecated) alternative to limit keyword arguments
        cmap : ~matplotlib.colors.Colormap, optional
            the :class:`~matplotlib.colors.Colormap`.
            Defaults to `matplotlib.cm.jet`
        float xmin, xmax, ymin, ymax, datamin, datamax : float, optional
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
        colorbar : bool, optional
            plot a color bar in specified orientation if not `None`
        axes : ~matplotlib.axes.Axes, optional
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
        figaspect : float, optional
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is `auto`, the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            cmap=cmap,
                                            colorbar=colorbar,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)

        self.axes.set_xlim(xmin=self._getLimit('xmin'),
                           xmax=self._getLimit('xmax'))

        self.axes.set_ylim(ymin=self._getLimit('ymin'),
                           ymax=self._getLimit('ymax'))

        if title is None:
            self.axes.set_title(self.vars[0].name)
示例#7
0
    def __init__(self,
                 vars,
                 title=None,
                 scale=None,
                 sparsity=None,
                 log=False,
                 limits={},
                 axes=None,
                 figaspect='auto',
                 **kwlimits):
        """Creates a `Matplotlib2DViewer`.

        :Parameters:
          vars
            a rank-1 `CellVariable` or `FaceVariable` object.
          title
            displayed at the top of the `Viewer` window
          scale
            if not `None`, scale all arrow lengths by this value
          sparsity
            if not `None`, then this number of arrows will be
            randomly chosen (weighted by the cell volume or face area)
          log
            if `True`, arrow length goes at the base-10 logarithm of the magnitude
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)

        self.quiver(sparsity=sparsity, scale=scale)
        self.log = log

        self._plot()
示例#8
0
    def __init__(self, vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits):
        """
        Creates a `Matplotlib2DGridViewer`.

        :Parameters:
          vars
            A `CellVariable` object.
          title
            displayed at the top of the `Viewer` window
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          cmap
            The colormap. Defaults to `matplotlib.cm.jet`
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          colorbar
            plot a colorbar in specified orientation if not `None`
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title,
                                            cmap=cmap, colorbar=colorbar, axes=axes, figaspect=figaspect,
                                            **kwlimits)

        xmin, ymin = self.vars[0].mesh.extents['min']
        xmax, ymax = self.vars[0].mesh.extents['max']

        self.image = self.axes.imshow(self._data,
                                      extent=(xmin, xmax, ymin, ymax),
                                      vmin=0, vmax=1,
                                      cmap=self.cmap)

        self.axes.set_xlim(xmin=self._getLimit('xmin'),
                           xmax=self._getLimit('xmax'))

        self.axes.set_ylim(ymin=self._getLimit('ymin'),
                           ymax=self._getLimit('ymax'))

        if title is None:
            self.axes.set_title(self.vars[0].name)
示例#9
0
    def __init__(self, vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, number=10, levels=None, figaspect='auto', **kwlimits):
        """Creates a `Matplotlib2DContourViewer`.

        Parameters
        ----------
        vars : ~fipy.variables.cellVariable.CellVariable
            `Variable` to display
        title : str, optional
            displayed at the top of the `Viewer` window
        limits : dict, optional
            a (deprecated) alternative to limit keyword arguments
        float xmin, xmax, ymin, ymax, datamin, datamax : float, optional
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
        cmap : ~matplotlib.colors.Colormap, optional
            the Colormap.
            Defaults to `matplotlib.cm.jet`
        colorbar : bool, optional
            plot a color bar in specified orientation if not `None`
        axes : ~matplotlib.axes.Axes, optional
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
        number : int, optional
            contour `number` automatically-chosen levels
        levels : :obj:`list` of :obj:`float`, optional
            A list of numbers indicating the level
            curves to draw; e.g. to draw just the zero contour pass
            ``levels=[0]``
        figaspect : float
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is `auto`, the aspect ratio will be determined from
            the Variable's mesh.

        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title,
                                            cmap=cmap, colorbar=colorbar, axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)
        self.number = number
        self.levels = levels

        self._plot()
示例#10
0
    def __init__(self, vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, number=10, levels=None, figaspect='auto', **kwlimits):
        """Creates a `Matplotlib2DContourViewer`.

        :Parameters:
          vars
            a `CellVariable` object.
          title
            displayed at the top of the `Viewer` window
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          cmap
            the colormap. Defaults to `matplotlib.cm.jet`
          colorbar
            plot a colorbar in specified orientation if not `None`
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          number
            contour `number` automatically-chosen levels
          *levels* [level0, level1, ..., leveln]
            A list of floating point numbers indicating the level
            curves to draw; e.g. to draw just the zero contour pass
            ``levels=[0]``
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.

        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self, vars=vars, title=title,
                                            cmap=cmap, colorbar=colorbar, axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)
        self.number = number
        self.levels = levels

        self._plot()
示例#11
0
    def __init__(self,
                 vars,
                 title=None,
                 log=False,
                 limits={},
                 axes=None,
                 figaspect='auto',
                 density=1,
                 linewidth=None,
                 color=None,
                 cmap=None,
                 norm=None,
                 arrowsize=1,
                 arrowstyle='-|>',
                 minlength=0.1,
                 **kwlimits):
        """Creates a `MatplotlibStreamViewer`.

        :Parameters:
          vars
            a rank-1 `CellVariable` or `FaceVariable` object.
          title
            displayed at the top of the `Viewer` window
          log
            if `True`, arrow length goes at the base-10 logarithm of the magnitude
          limits : dict
            a (deprecated) alternative to limit keyword arguments
          xmin, xmax, ymin, ymax, datamin, datamax
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
          axes
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
          figaspect
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is 'auto', the aspect ratio will be determined from
            the Variable's mesh.
          *density* : float or 2-tuple
              Controls the closeness of streamlines. When `density = 1`, the domain
              is divided into a 25x25 grid---*density* linearly scales this grid.
              Each cell in the grid can have, at most, one traversing streamline.
              For different densities in each direction, use [density_x, density_y].
          linewidth : Numeric or rank-0 `MeshVariable`
            vary linewidth when given a `CellVariable` or `FaceVariable` of same
            type as vars.
          *color* : matplotlib color code, or rank-0 `MeshVariable`
              Streamline color. When given an array with the type as vars,
              *color* values are converted to colors using *cmap*.
          *cmap* : :class:`~matplotlib.colors.Colormap`
              Colormap used to plot streamlines and arrows. Only necessary when using
              an `MeshVariable` input for *color*.
          *norm* : :class:`~matplotlib.colors.Normalize`
              Normalize object used to scale luminance data to 0, 1. If None, stretch
              (min, max) to (0, 1). Only necessary when *color* is an `MeshVariable`.
          *arrowsize* : float
              Factor scale arrow size.
          *arrowstyle* : str
              Arrow style specification.
              See :class:`~matplotlib.patches.FancyArrowPatch`.
          *minlength* : float
              Minimum length of streamline in axes coordinates.

        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)

        self.log = log
        self.kwargs = dict(density=density,
                           cmap=cmap,
                           norm=norm,
                           arrowsize=arrowsize,
                           arrowstyle=arrowstyle,
                           minlength=minlength)
        self.linewidth = linewidth
        self.color = color

        self._stream = None

        self._plot()
示例#12
0
    def __init__(self,
                 vars,
                 title=None,
                 log=False,
                 limits={},
                 axes=None,
                 figaspect='auto',
                 density=1,
                 linewidth=None,
                 color=None,
                 cmap=None,
                 norm=None,
                 arrowsize=1,
                 arrowstyle='-|>',
                 minlength=0.1,
                 **kwlimits):
        """Creates a `MatplotlibStreamViewer`.

        Parameters
        ----------
        vars : ~fipy.variables.cellVariable.CellVariable or ~fipy.variables.faceVariable.FaceVariable
            rank-1 `Variable` to display
        title : str, optional
            displayed at the top of the `Viewer` window
        log : bool, optional
            if `True`, arrow length goes at the base-10 logarithm of the magnitude
        limits : dict, optional
            a (deprecated) alternative to limit keyword arguments
        float xmin, xmax, ymin, ymax, datamin, datamax : float
            displayed range of data. Any limit set to
            a (default) value of `None` will autoscale.
        axes : ~matplotlib.axes.Axes, optional
            if not `None`, `vars` will be plotted into this Matplotlib `Axes` object
        figaspect : float, optional
            desired aspect ratio of figure. If arg is a number, use that aspect
            ratio. If arg is `auto`, the aspect ratio will be determined from
            the Variable's mesh.
        density : float or (float, float), optional
            Controls the closeness of streamlines.  When ``density = 1``,
            the domain is divided into a 30x30 grid.  *density* linearly
            scales this grid.  Each cell in the grid can have, at most, one
            traversing streamline.  For different densities in each
            direction, use a tuple (density_x, density_y).
        linewidth : array_like or ~fipy.variables.cellVariable.CellVariable or ~fipy.variables.faceVariable.FaceVariable, optional
            The width of the stream lines.  With a rank-0 `CellVariable` or
            `FaceVariable` the line width can be varied across the grid.
            The MeshVariable must have the same type and be defined on
            the same `Mesh` as *vars*.
        color : str or ~fipy.variables.cellVariable.CellVariable or ~fipy.variables.faceVariable.FaceVariable, optional
            The streamline color as a matplotlib color code or a field of
            numbers.  If given a rank-0 `CellVariable` or `FaceVariable`,
            its values are converted to colors using *cmap* and *norm*.
            The MeshVariable must have the same type and be defined on the
            same `Mesh` as *vars*.
        cmap : ~matplotlib.colors.Colormap, optional
            Colormap used to plot streamlines and arrows.  This is only
            used if *color* is a MeshVariable.
        norm : ~matplotlib.colors.Normalize, optional
            Normalize object used to scale luminance data to 0, 1.  If
            ``None``, stretch (min, max) to (0, 1).  Only necessary when
            *color* is a MeshVariable.
        arrowsize : float, optional
            Scaling factor for the arrow size.
        arrowstyle : str, optional
            Arrow style specification.
            See `~matplotlib.patches.FancyArrowPatch`.
        minlength : float, optional
              Minimum length of streamline in axes coordinates.

        """
        kwlimits.update(limits)
        AbstractMatplotlib2DViewer.__init__(self,
                                            vars=vars,
                                            title=title,
                                            axes=axes,
                                            figaspect=figaspect,
                                            **kwlimits)

        self.log = log
        self.kwargs = dict(density=density,
                           cmap=cmap,
                           norm=norm,
                           arrowsize=arrowsize,
                           arrowstyle=arrowstyle,
                           minlength=minlength)
        self.linewidth = linewidth
        self.color = color

        self._stream = None

        self._plot()