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)[source]¶ base class for plotting objects
-
class
nutils.plot.
PyPlot
(name=None, imgtype=None, ndigits=3, index=None, **kwargs)[source]¶ matplotlib figure
-
mesh
(points, values=None, edgecolors='k', edgewidth=0.1, mergetol=0, setxylim=True, aspect='equal', tight=True, **kwargs)[source]¶ plot elemtwise mesh
-
slope_marker
(x, y, slope=None, width=0.2, xoffset=0, yoffset=0.2, color='0.5')[source]¶ slope marker
-
slope_triangle
(x, y, fillcolor='0.9', edgecolor='k', xoffset=0, yoffset=0.1, slopefmt='{0:.1f}')[source]¶ 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
-
-
class
nutils.plot.
PyPlotVideo
(name, videotype=None, clearfigure=True, framerate=24)[source]¶ matplotlib based video generator
Video generator based on matplotlib figures. Follows the same syntax as PyPlot.
Parameters: - clearfigure (bool, default: True) – If True 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 property
videotype
) – 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. - properties (Nutils) –
- ----------------- –
- videotype – see parameter with the same name
- videoencoder (str, default: 'ffmpeg') – Name or path of the video encoder. The video encoder should take the same arguments as ‘ffmpeg’.
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()