fipy.viewers.matplotlibViewer¶
Functions
|
Generic function for creating a MatplotlibViewer. |
- fipy.viewers.matplotlibViewer.MatplotlibViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, **kwlimits)¶
Generic function for creating a MatplotlibViewer.
The MatplotlibViewer factory will search the module tree and return an instance of the first MatplotlibViewer it finds of the correct dimension and rank.
It is possible to view different
Variable
s against different Matplotlib Axes>>> from matplotlib import pyplot as plt >>> from fipy import *
>>> plt.ion() >>> fig = plt.figure()
>>> ax1 = plt.subplot((221)) >>> ax2 = plt.subplot((223)) >>> ax3 = plt.subplot((224))
>>> k = Variable(name="k", value=0.)
>>> mesh1 = Grid1D(nx=100) >>> x, = mesh1.cellCenters >>> xVar = CellVariable(mesh=mesh1, name="x", value=x) >>> viewer1 = MatplotlibViewer(vars=(numerix.sin(0.1 * k * xVar), numerix.cos(0.1 * k * xVar / numerix.pi)), ... limits={'xmin': 10, 'xmax': 90}, ... datamin=-0.9, datamax=2.0, ... title="Grid1D test", ... axes=ax1, ... legend=None)
>>> mesh2 = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh2.cellCenters >>> xyVar = CellVariable(mesh=mesh2, name="x y", value=x * y) >>> viewer2 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Grid2D test", ... axes=ax2, ... colorbar=None)
>>> mesh3 = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh3.cellCenters >>> xyVar = CellVariable(mesh=mesh3, name="x y", value=x * y) >>> viewer3 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Irregular 2D test", ... axes=ax3, ... cmap = plt.cm.OrRd)
>>> viewer = MultiViewer(viewers=(viewer1, viewer2, viewer3)) >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot()
>>> viewer._promptForOpinion()
- Parameters:
vars (
CellVariable
orlist
) – the Variable objects to display.title (
str
, optional) – displayed at the top of the Viewer windowlimits (
dict
) – a (deprecated) alternative to limit keyword argumentsxmin (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.xmax (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.ymin (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.ymax (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.datamin (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.datamax (
float
, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.cmap (
Colormap
, optional) – theColormap
. Defaults to matplotlib.cm.jetcolorbar (
bool
, optional) – plot a color bar in specified orientation if not Noneaxes (
Axes
, optional) – if not None, vars will be plotted into this Matplotlib Axes object
Modules
Test numeric implementation of the mesh |