yade.plot module

Module containing utility functions for plotting inside yade. See scripts/simple-scene-plot.py or examples/concrete/uniax.py for example of usage.

yade.plot.data

Global dictionary containing all data values, common for all plots, in the form {‘name’:[value,...],...}. Data should be added using plot.addData function. All [value,...] columns have the same length, they are padded with NaN if unspecified.

yade.plot.plots

dictionary x-name -> (yspec,...), where yspec is either y-name or (y-name,’line-specification’)

yade.plot.labels

Dictionary converting names in data to human-readable names (TeX names, for instance); if a variable is not specified, it is left untranslated.

yade.plot.live

Enable/disable live plot updating. Disabled by default for now, since it has a few rough edges.

yade.plot.liveInterval

Interval for the live plot updating, in seconds.

yade.plot.autozoom

Enable/disable automatic plot rezooming after data update.

yade.plot.plot(noShow=False, subPlots=False)

Do the actual plot, which is either shown on screen (and nothing is returned: if noShow is False) or, if noShow is True, returned as matplotlib’s Figure object or list of them.

You can use

>>> from yade import plot
>>> plot.plots={'foo':('bar',)}
>>> plot.plot(noShow=True).savefig('someFile.pdf')
>>> import os
>>> os.path.exists('someFile.pdf')
True

to save the figure to file automatically.

Note

For backwards compatibility reasons, noShow option will return list of figures for multiple figures but a single figure (rather than list with 1 element) if there is only 1 figure.

yade.plot.reset()

Reset all plot-related variables (data, plots, labels)

yade.plot.resetData()

Reset all plot data; keep plots and labels intact.

yade.plot.splitData()

Make all plots discontinuous at this point (adds nan’s to all data fields)

yade.plot.addData(*d_in, **kw)

Add data from arguments name1=value1,name2=value2 to yade.plot.data. (the old {‘name1’:value1,’name2’:value2} is deprecated, but still supported)

New data will be left-padded with nan’s, unspecified data will be nan. This way, equal length of all data is assured so that they can be plotted one against any other.

Nan’s don’t appear in graphs.

yade.plot.saveGnuplot(baseName, term='wxt', extension=None, timestamp=False, comment=None, title=None, varData=False)

Save data added with plot.addData into (compressed) file and create .gnuplot file that attempts to mimick plots specified with plot.plots.

Parameters:
  • baseName – used for creating baseName.gnuplot (command file for gnuplot), associated baseName.data.bz2 (data) and output files (if applicable) in the form baseName.[plot number].extension
  • term – specify the gnuplot terminal; defaults to x11, in which case gnuplot will draw persistent windows to screen and terminate; other useful terminals are png, cairopdf and so on
  • extension – extension for baseName defaults to terminal name; fine for png for example; if you use cairopdf, you should also say extension='pdf' however
  • timestamp (bool) – append numeric time to the basename
  • varData (bool) – whether file to plot will be declared as variable or be in-place in the plot expression
  • comment – a user comment (may be multiline) that will be embedded in the control file
Returns:

name of the gnuplot file created.

yade.plot.saveDataTxt(fileName, vars=None)

Previous topic

yade.pack module

Next topic

yade.post2d module

This Page