plot¶
The plot module aims to provide a consistent interface to various plotting backends. At this point matplotlib and vtk are supported.
-
class
nutils.plot.
BasePlot
(name=None, ndigits=0, index=None)¶ Bases:
object
base class for plotting objects
-
__init__
(self, name=None, ndigits=0, index=None)¶ constructor
-
__enter__
(self)¶ enter with block
-
__exit__
(self, exc_type, exc_value, exc_tb)¶ exit with block
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
nutils.plot.
PyPlot
(name=None, imgtype=None, ndigits=3, index=None, **kwargs)¶ Bases:
nutils.plot.BasePlot
matplotlib figure
-
__init__
(self, name=None, imgtype=None, ndigits=3, index=None, **kwargs)¶ constructor
-
__enter__
(self)¶ enter with block
-
close
(self)¶ close figure
-
save
(self, name=None, index=None, **kwargs)¶ save images
-
segments
(self, points, color='black', **kwargs)¶ plot line
-
mesh
(self, points, values=None, edgecolors='k', edgewidth=0.1, mergetol=0, setxylim=True, aspect='equal', tight=True, **kwargs)¶ plot elemtwise mesh
-
polycol
(self, verts, facecolors='none', **kwargs)¶ add polycollection
-
slope_marker
(self, x, y, slope=None, width=0.2, xoffset=0, yoffset=0.2, color='0.5')¶ slope marker
-
slope_triangle
(self, x, y, fillcolor='0.9', edgecolor='k', xoffset=0, yoffset=0.1, slopefmt='{0:.1f}')¶ Draw slope triangle for supplied y(x) - x, y: coordinates - xoffset, yoffset: distance graph & triangle (points) - fillcolor, edgecolor: triangle style - slopefmt: format string for slope number
-
slope_trend
(self, x, y, lt='k-', xoffset=0.1, slopefmt='{0:.1f}')¶ Draw slope triangle for supplied y(x) - x, y: coordinates - slopefmt: format string for slope number
-
rectangle
(self, x0, w, h, fc='none', ec='none', **kwargs)¶
-
griddata
(self, xlim, ylim, data)¶ plot griddata
-
cspy
(self, A, **kwargs)¶ Like pyplot.spy, but coloring acc to 10^log of absolute values, where [0, inf, nan] show up in blue.
-
-
class
nutils.plot.
PyPlotVideo
(name, videotype=None, clearfigure=True, framerate=24)¶ Bases:
nutils.plot.PyPlot
matplotlib based video generator
Video generator based on matplotlib figures. Follows the same syntax as PyPlot.
Parameters: - clearfigure (
bool
, default:True
) – IfTrue
clears the matplotlib figure after writing each frame. - framerate (
int
,float
, default:24
) – Framerate in frames per second of the generated video. - videotype (
str
, default:'webm'
unless overriden by propertyvideotype
) – Video type of the generated video. Note that not every video type supports playback before the video has been finalized, i.e. beforeclose
has been called.
Examples
Using a
with
-statement:video = PyPlotVideo('video') for timestep in timesteps: ... with video: video.plot(...) video.title('frame {:04d}'.format(video.frame)) video.close()
Using
saveframe
:video = PyPlotVideo('video') for timestep in timesteps: ... video.plot(...) video.title('frame {:04d}'.format(video.frame)) video.saveframe() video.close()
-
__init__
(self, name, videotype=None, clearfigure=True, framerate=24)¶ constructor
-
__enter__
(self)¶ enter with block
-
__exit__
(self, exc_type, exc_value, exc_tb)¶ exit with block
-
saveframe
(self)¶ add a video frame
-
close
(self)¶ finalize video
- clearfigure (
-
class
nutils.plot.
DataFile
(name=None, index=None, ext='txt', ndigits=0)¶ Bases:
nutils.plot.BasePlot
data file
-
__init__
(self, name=None, index=None, ext='txt', ndigits=0)¶ constructor
-
-
class
nutils.plot.
VTKFile
(name=None, index=None, ndigits=0, ascii=False)¶ Bases:
nutils.plot.BasePlot
vtk file
-
__init__
(self, name=None, index=None, ndigits=0, ascii=False)¶ constructor
-
rectilineargrid
(self, coords)¶ set rectilinear grid
-
unstructuredgrid
(self, cellpoints, npars=None)¶ set unstructured grid
-
celldataarray
(self, name, data)¶ add cell array
-
pointdataarray
(self, name, data)¶ add cell array
-
-
nutils.plot.
writevtu
(name, topo, coords, pointdata={}, celldata={}, ascii=False, superelements=False, maxrefine=3, ndigits=0, ischeme='gauss1', **kwargs)¶ write vtu from coords function