2D Plotting nodes#
Overview#
VisuAlea nodes related to pylab 2D-plotting functionalities are available within
this module openalea.pylab_plotting_wralea.py_pylab. They are all based
upon the base class Plotting
that provides a common interface.
In addition, plots related to curves (plot, semilogx, csd, …) have common x-y inputs
and curves can be customised in the same way. So, we derived them from a common
class called openalea.pylab_plotting_wralea.py_pylab.PlotxyInterface.
In order to tune the curves, matplotlib provides many parameters. In the visual programming environment, VisuAlea, this implies far too many connectors. Therefore, based on matplotlib, we prefered to provide a dictionary called Line2D as a special node to set the lines parameters.
Base classes#
|
This class provides common connectors to plotting nodes that are defined in this module. |
A base class common to some plotting functions |
Special Line2D node#
This node converts a x and y arrays into a fully customisable object.
Convert x and y inputs into a pylab.Line2D objects. |
Plots where x and y are 1-D arrays or Line2D objects#
Plot the autocorrelation of x. |
|
Make a box and whisker plot. |
|
adds labels to line contours. |
|
Plot the coherence between x and y (normalized cross spectral density). |
|
See pylab.colorbar for details |
|
make a contour plot of an array Z. |
|
|
The cross spectral density. |
Plot x versus y with error deltas in yerr and xerr. |
|
Plot filled polygons. |
|
Create a filled regions between 2 functions. |
|
Make a hexagonal binning plot of x versus y. |
|
Compute and draw the histogram of x. |
|
Display the image in X to current axes. |
|
Make a plot with log scaling. |
|
Create a pseudocolor plot of a 2-D array. |
|
|
Make a pie chart of array x. |
Plot lines. |
|
Make a polar plot. |
|
|
The power spectral density. |
Plot a 2-D field of arrows. |
|
Make scatter plot of x versus y. |
|
Make a plot with log scaling on x-axis. |
|
Make a plot with log scaling on y-axis. |
|
Compute a spectrogram of data in x. |
|
A stem plot plots vertical lines. |
|
Make a step plot. |
|
Plot the crosscorrelation of x with y. |
Api#
Pylab plotting nodes for VisuAlea
- class openalea.pylab_plotting_wralea.py_pylab.Plotting(inputs={})[source]#
This class provides common connectors to plotting nodes that are defined in this module.
Classes that inherits from ~openalea.pylab.plotting.Plotting are ensured to inherits from Node and to have a common API where:
the first input connector is reserved for connecting a pylab axes
the first output connector is reserved for connecting a pylab axes
the last input connector is reseverd to set the pylab.figure number
It also provides several methods that check validity of input axes, update the figure and so on.
- ERROR_FAILURE = 'Failed to generate the image. check your entries.'#
- ERROR_NOXDATA = 'No data connected to the x connector. Connect a line2D, an array or a list of line2Ds or arrays'#
- axes()[source]#
manage the pylab axes.
If no axes is connected to the first input connector, then a new one will be created except if current node has already generated an axes (was already called). In such case, the node’s axes is cleared.
If an axes is connected, the current axes is set to this input axes. It is not clear but used to to plot data generated by the current node on top of this connected axes.
- figure()[source]#
calls pylab.figure() taking care of existing figure
If a node is executed for the first time, the figure object is stored. This is useful in cases where thre user kills the figure manually. In such case, we clean the axes that are left in memory before creating a new figure.
- update_figure(type=None)[source]#
This method updates the figure using pylab.figure.canvas.draw and pylab.show methods
Warning
This function seems to prevent the matplotlib plot_directive sphinx extension to work properly. When you want to generate the sphinx documentation, comment the code to get the best output possible.
- class openalea.pylab_plotting_wralea.py_pylab.PlotxyInterface[source]#
A base class common to some plotting functions
The plotting functions that uses this base class are those that plot 2D curves (xy). For instance:
plot
loglog
semilogx, semilogy
csd, psd, specgram
stem
step
fill
This is used to manage the different possible x and y inputs. See
PyLabPlotfor more explanation.For more tunable colors and linestyles, use the
Line2Dconvertor before passing the data to a node.This class provides a method
call()that manage the inputs data and arguments smoothly.- ERROR_FAILURE = 'Failed to generate the image. check your entries.'#
- ERROR_NOXDATA = 'No data connected to the x connector. Connect a line2D, an array or a list of line2Ds or arrays'#
- class openalea.pylab_plotting_wralea.py_pylab.PyLabAcorr[source]#
Plot the autocorrelation of x. See pylab.acorr for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – an input array
maxlags (int) – a positive integer detailing the number of lags to show. (default None means
lags).density (bool) – if True, draw and return a probability density: each bin will display the bin’s raw count divided by the total number of counts and the bin width.
usevlines (bool) – If True,
vlines()rather thanplot()is used to draw vertical lines from the origin to the acorr. Otherwise, the plot style is determined by the kwargs, which areLine2Dproperties. (default True)detrend (str) – apply a linear or mean detrend if not None (default is None)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.figure (int) – figure id
- Returns:
The first connector is the current axe.
The second connector is the output of pylab.acorr that is a tuple (lags, c, linecol, b)
See also
in VisuAlea, see pylab/test/acorr composite node.
PyLabXcorr- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabBoxPlot[source]#
Make a box and whisker plot. See pylab.boxplot for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – data
notch (bool) – 0 (default) makes a rectangular box plot, 1 makes a notched box plot.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
color (str) – a color selected from the list or connecte to
colornode to select any color from the wheel color.vert (bool) – 1 (default) makes the boxes vertical, 0 makes horizontal boxes.
whis (float) – (default 1.5) defines the length of the whiskers as a function of the inner quartile range. They extend to the most extreme data point within (
whis*(75%-25%)) data range.sym (str) – (default ‘b+’) is the default symbol for flier points. Enter an empty string (‘’) if you don’t want to show fliers.
positions – (default 1,2,…,n) sets the horizontal positions of the boxes. The ticks and limits are automatically set to match the positions
widths (float) – either a scalar or a vector and sets the width of each box. The default is 0.5, or
0.15*(distance between extreme positions)if that is smaller.bootstrap (int) – see pylab.boxplot for details
figure (int) – figure id
See also
in VisuAlea, see pylab/test/boxplot composite node.
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabCLabel[source]#
adds labels to line contours. See pylab.clabel for details.
See also
- class openalea.pylab_plotting_wralea.py_pylab.PyLabCohere[source]#
Plot the coherence between x and y (normalized cross spectral density). See pylab.cohere for details.
- A function or a vector of length NFFT. To create window
vectors see
window_hanning(),window_none(),numpy.blackman(),numpy.hamming(),numpy.bartlett(),scipy.signal(),scipy.signal.get_window(), etc. The default iswindow_hanning(). If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – an input array
y (array) – an input array
NFFT (int) – The number of data points used in each block for the FFT. The default is 256. Must be even; a power 2 is most efficient.
Fs (float) – The sampling frequency (default is 2).
Fc (float) – The center frequency of x (default is 0).
detrend (str) – The function applied to each segment before fft-ing, designed to remove the mean or linear trend (default is ‘none’)
window (str) – function or a vector of length NFFT. default is hanning window To create other window, use the
PyLabWindownode.noverlap (int) – The number of points of overlap between blocks. (default is 0, no overlap).
pad_to (int) – The number of points to which the data segment is padded when performing the FFT (default is None)
sides (str) – Specifies which sides of the PSD to return (default is ‘default’).
scale_by_freq (bool) – (default is True)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabColorBar[source]#
See pylab.colorbar for details
- Parameters:
ax – an optional axes where colorbar will be added
cax – an optional axes where colorbar will be added
orientation (str) – vertical or horizontal
fraction (float) – fraction of original axes to use for colorbar (default is 0.15)
pad (float) – fraction of original axes between colorbar and new image axes (default is 0.15)
shrink (float) – fraction by which to shrink the colorbar (default 1)
aspect (float) – ratio of long to short dimensions (default is 20)
extend (str) – [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ] (default ‘neither’) If not ‘neither’, make pointed end(s) for out-of-range values.
spacing (str) – [ ‘uniform’ | ‘proportional’ ] Uniform spacing gives each discrete color the same space; proportional makes the space proportional to the data interval.
ticks (str) – [ None | list of ticks | Locator object ] If None, ticks are determined automatically from the input.
format (str) – format string e.g. ‘%.3f’, that is used.
drawedges (bool) – if True, draw lines at color boundaries
cmap – a colormap (default jet). See
PyLabColorMapnode.figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabContour[source]#
make a contour plot of an array Z. The level values are chosen automatically. See pylab.contour for details.
- Parameters:
axes – an optional axes where new data will be plotted.
X (array) – a 2D array
y (array) – a 2D array
Z (array) – a 2D array
N (int) – if an int is provided, contour N automatically-chosen levels. If an array is provided, draw contour lines at the values specified in sequence V.
linewidth (float) – width of a line in points (default is 1)
linestyle (str) – The linestyle of a curve [None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
color (str) – a color selected from the list or connected to
colornode to select any color from the wheel color.alpha (float) – The alpha blending value. (default is 1.0)
cmap – a colormap (default jet). See
PyLabColorMapnode.norm – [ None | Normalize ] A
matplotlib.colors.Normalizeinstance for scaling data values to colors. If norm is None and colors is None.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]origin – [ None | ‘upper’ | ‘lower’ | ‘image’ ] If None, the first value of Z will correspond to the lower left corner, location (0,0). If ‘image’, the rc value for
image.originwill be used. This keyword is not active if X and Y are specified in the call to contour.extent – [ None | (x0,x1,y0,y1) ] This keyword is not active if X and Y are specified.
locator – [ None | ticker.Locator subclass ]. The locator is used to determine the contour levels if they are not given explicitly via the V argument.
extend (str) – [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ] (default ‘neither’) If not ‘neither’, make pointed end(s) for out-of-range values.
xunits – [ None | registered units ]
yunits – [ None | registered units ]
filled (bool)
figure (int) – figure int
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabCsd[source]#
The cross spectral density. See pylab.csd for details
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – input x array
y (array) – input y array
NFFT – The number of data points used in each block for the FFT. The default is 256. Must be even; a power 2 is most efficient.
Fs – The sampling frequency. The default is 2.
Fc – The center frequency of x. Default is 0.
detrend (str) – The function applied to each segment before fft-ing, designed to remove the mean or linear trend (default is ‘none’)
window (str) – function or a vector of length NFFT. default is hanning window To create other window, use the
PyLabWindownode.noverlap – The number of points of overlap between blocks. The default value is 0.
pad_to (int) – The number of points to which the data segment is padded when performing the FFT (default is None)
sides (str) – Specifies which sides of the PSD to return (default is ‘default’).
scale_by_freq (bool) – (default is True)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabErrorBar[source]#
Plot x versus y with error deltas in yerr and xerr. See pylab.errorbar for details.
Vertical errorbars are plotted if yerr is not None. Horizontal errorbars are plotted if xerr is not None.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – 1D x array
y (array) – 1D y array
xerr (array) – 1D x error array
yerr (array) – 1D y error array (optional)
fmt (str) – The plot format symbol. If fmt is None, only the errorbars are plotted.
ecolor (str) – a color for the error bars selected from the list or connected to a
colornode.elinewidth (float) – the linewidth of the errorbars in points (default is 1)
capsize (int) – the size of the error bar caps in points (default 3)
barsabove (bool) – if True, will plot the errorbars above the plot symbols. Default is below.
lolims (bool) – (default is False)
uplims (bool) – (default is False)
xuplims (bool) – (default is False)
xlolims (bool) – (default is False)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.
- Returns:
the axes in which the data are plotted.
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabFill[source]#
Plot filled polygons. See pylab.fill for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – 1D array
y (array) – 1D array
linewidth (float) – width of a line in points (default is 1)
facecolor (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.kwargs (dict) – control the Polygon properties by connecting a
PyLabPatchDictionary.
- Returns:
the axes in which the data are plotted.
- Returns:
list of
Patchinstances that were added.- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabFillBetween[source]#
Create a filled regions between 2 functions. See pylab.fillbetween for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – 1D array of size N
y1 (array) – 1D array of size N
y2 (array) – 1D array of size N
where (str) – if None, default to fill between everywhere. If not None, fill region where
where==True. For instance where can be ‘y1>y2’, ‘y1>0’.interpolate (bool) – if True, interpolate between the two lines to find precise point of intersection.
patch – connect a
Patch.
- Returns:
the axes in which the data are plotted.
- Example:
Note
a more complex example can be found in the openalea.pylab.demo.fill_between composite node.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabHexBin[source]#
Make a hexagonal binning plot of x versus y. See pylab.hexbin for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – a 1D array
y – a 1D array
C – If C is specified, it specifies values at the coordinate (x[i],y[i])
gridsize (int) – the number of hexagons in the x and y directions.
bins –
[ None | ‘log’ | integer | sequence ] * If None, no binning is applied; the color of each hexagon directly corresponds to its count value. * If ‘log’, use a logarithmic scale for the color map. Internally,
is used todetermine the hexagon color.
If an integer, divide the counts in the specified number of bins, and color the hexagons accordingly.
If a sequence of values, the values of the lower bound of the bins to be used.
xscale (str) – [ ‘linear’ | ‘log’ ] Use a linear or log10 scale on the horizontal axis.
yscale (str) – [ ‘linear’ | ‘log’ ] Use a linear or log10 scale on the vertical axis.
cmap – a colormap (default jet). See
PyLabColorMapnode.norm – [ None | Normalize ]
matplotlib.colors.Normalizeinstance is used to scale luminance data to 0,1.vmin (float) – used in conjunction with norm to normalize luminance data. If either min or max are None, the min and max of the color array C is used.
vmax (float) – used in conjunction with norm to normalize luminance data. If either vmin or vmax are None, the min and max of the color array C is used.
alpha (float) – The alpha blending value. (default is 1.0)
linewidths (float) – width of lines in points (default is None)
edgecolors (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.reduce_C_function – numpy.mean function
mincnt (int) – None | a positive integer, if not None, only display cells with more than mincnt number of points in the cell
marginals (bool) – if marginals is True, plot the marginal density as colormapped rectangles along the bottom of the x-axis and left of the y-axis
extent (float) – [ None | scalars (left, right, bottom, top) ] The limits of the bins. The default assigns the limits based on gridsize, x, y, xscale and yscale.
kwargs (dict) – Connect a dictionary to further tune the polygons.
figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabHist[source]#
Compute and draw the histogram of x. See pylab.hist for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – the input data (1D array)
bins (int) – binning number (default is 10)
facecolor (str) – (default is blue)
normed (bool) – if True, the first element of the return tuple will be the counts normalized to form a probability density (default is False).
cumulative (bool) – draw cumulated histogram (default False)
histtype (str) – The type of histogram to draw [ ‘bar’ | ‘barstacked’ | ‘step’ | ‘stepfilled’ ]
align (str) – Controls how the histogram is plotted [‘left’ | ‘mid’ | ‘right’ ]
orientation (str) – horizontal or vertical (default vertical)
log (bool) – logarithmic scale (default is False)
label (str) – a text label for the legend
kwargs – a
PyLabLine2Dobjectfigure (int) – figure id
- Returns:
The first connector is the current axe.
The second connector is the output of pylab.hist that is a tuple (lags, c, linecol, b)
- class openalea.pylab_plotting_wralea.py_pylab.PyLabImshow[source]#
Display the image in X to current axes. See pylab.imshow for details.
- Parameters:
axes – an optional axes where new data will be plotted.
X – a 2D array
cmap – a colormap (default jet). See
PyLabColorMapnode.interpolation (str) – select interpolation method. If None default to rc
image.interpolation. See also the filternorm and filterrad parametersaspect (str) –
If ‘auto’, changes the image aspect ratio to match that of the axes
If ‘equal’, and extent is None, changes the axes aspect ratio to match that of the image.
If extent is not None, the axes aspect ratio is changed to match that of the extent.
If None, default to rc
image.aspectvalue.
alpha (float) – The alpha blending value. (default is 1.0)
vmin (float) – used in conjunction with norm to normalize luminance data. If either min or max are None, the min and max of the color array C is used.
vmax (float) – used in conjunction with norm to normalize luminance data. If either vmin or vmax are None, the min and max of the color array C is used.
origin – [ None | ‘upper’ | ‘lower’ | ‘image’ ] If None, the first value of Z will correspond to the lower left corner, location (0,0). If ‘image’, the rc value for
image.originwill be used. This keyword is not active if X and Y are specified in the call to contour.extent – [ None | scalars (left, right, bottom, top) ] Data limits for the axes. The default assigns zero-based row, column indices to the x, y centers of the pixels.
shape – [ None | scalars (columns, rows) ] For raw buffer images
filternorm – see pylab.imshow for details
filterrad – filter radius for filters that have a radius parameter, i.e. when interpolation is one of: ‘sinc’, ‘lanczos’ or ‘blackman’
arrangment – non-pylab option. See below
kwargs – extra arguments if required
- Additional argument:
arrangment a tuple/list of 2 integers: If N images are connected to the input, the default behaviour is to use pylab.subplot to create a n x m grid such that n is close to m.
You can overwrite this arbitrary layout by setting yourself the n and m values using the arrangment but then n x m must be equal to N.
Note
if you set vmin or vmax, you cannot get back its original value (None) To reset them, either you need to reload the whole node, or set them to equal values like 0 and 0
- Returns:
The first connector is the current axe.
The second connector is the output of pylab.imshow
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabLine2D[source]#
Convert x and y inputs into a pylab.Line2D objects.
- Parameters:
xdata – a x array
ydata – a y array of same length as x
linestyle – a valid pylab linestyle
color – a valid pylab color
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize
markeredgewidth
markercolor
linewidth (float) – width of a line in points (default is 1)
fillstyle
label – a label that will be used when legend() is called
alpha (float) – The alpha blending value.
kwargs – all other valid Line2D properties (key/value)
- Returns:
a Line2D object that can be connected to some of the OpenAlea.PyLab nodes.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabLogLog[source]#
Make a plot with log scaling. See pylab.loglog for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – one or several arrays, or one or several PyLabLine2D objects.
y – one or several arrays, or one or several PyLabLine2D objects.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize (int) – marker size (default is 10)
linestyle (str) – The linestyle of a curve [None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
color (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.kwargs – a
PyLabLine2Dobject to fully tune the lines.figure (int) – figure id
- Returns:
the axes in which the data are plotted.
the output of plot function (line2d)
- Example:
See also
See
PyLabPlotfor details about the x and y connector.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabPcolor[source]#
Create a pseudocolor plot of a 2-D array. See pylab.pcolor for details.
- Parameters:
X (array) – a 2D array
Y (array) – a 2D array
Z (array) – a 2D array
cmap – a colormap (default jet). See
PyLabColorMapnode.norm – [ None | Normalize ] A
matplotlib.colors.Normalizeinstance for scaling data values to colors. If norm is None and colors is None.vmin (float) – used in conjunction with norm to normalize luminance data. If either min or max are None, the min and max of the color array C is used.
vmax (float) – used in conjunction with norm to normalize luminance data. If either vmin or vmax are None, the min and max of the color array C is used.
alpha (float) – The alpha blending value. (default is 1.0)
shading – [ ‘flat’ | ‘faceted’ ] * If ‘faceted’, a black grid is drawn around each rectangle * If ‘flat’, edges are not drawn. Default is ‘flat’, contrary to
kwargs – a dictionary to further customize polycollection.
figure (int) – figure id
- Example:
Note
pcolormesh is equivalent to pcolor.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabPie[source]#
Make a pie chart of array x. See pylab.pie for details.
The fractional area of each wedge is given by x/sum(x). If sum(x) <= 1, then the values of x give the fractional area directly and the array will not be normalized.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – a 1D array
colors (array) – a sequence of matplotlib color for each x element
labels (array) – a sequence of labels for each x element
explode (array) – sequence of fraction of the radius with which to offset each wedge.
autopct (array) – a string or function used to label the wedges with their numeric value. the wedge. If it is a format string, the label will be
fmt%pct.pctdistance (float) – ratio between the center of each pie slice and the text generated by autopct. (default is 0.6).
labeldistance (float) – radial distance at which the pie labels are drawn
shadow (bool) – draw a shadow beneath the pie (default is False).
figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabPlot[source]#
Plot lines. See pylab.plot help for details.
The x connector must be connected. It must be in one of the following format:
- a 1-D array.
If nothing is connected to y, then x is used as y (similarly to pylab.plot behaviour)
A 1-D array of same length may be connected to y.
Several 1-D arrays of same length as x may be connected to y. Therefore, these arrays have the same x data
a Line2D object (see Line2D). y must be empty in such case.
a list of Line2D objects. y must be empty in such case
In order to customize the input data at will, it is necesserary to convert the xy data into a
PyLabLine2Dobject and to pass it to the x connector. In such case, the y connector becomes useless.See also
the following dataflow example for illustrations
- Parameters:
axes – an optional axes where new data will be plotted.
x – one or several arrays, or one or several PyLabLine2D objects.
y – one or several arrays, or one or several PyLabLine2D objects.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize (int) – marker size (default is 10)
linestyle (str) – The linestyle of a curve [None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
color (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.scalex (bool) – determine whether x is autoscaled; the default is True.
scaley (bool) – determine whether x is autoscaled; the default is True.
kwargs – a
PyLabLine2Dobject to fully tune the lines.figure (int) – figure id
- Returns:
the axes in which the data are plotted.
the output of plot function (line2d)
- Example:
The 4 independent dataflows that can be seen here generate the four figures here below. The left upside dataflow has only a x array connected. It is as if you were typing:
plot(x)The right upside dataflow as a x and 1 y array connected. It is as if you were typing:
plot(x,y)
The left downside dataflow has 1 x and several y arrays. It is as if you were typing:
plot(x,y1, x, y2)
And finally, the right downside dataflow allows to convert x,y tuple into Line2D to further customize the line2D. It is as if you were typing:
plot(x1, y1, **kwds1) plot(x2, y2, **kwds2)
where kwds are valid arguments from the PyLabLine2D nodes.
See also
in VisuAlea, see “plot demos” in openalea.pylab.demo
- class openalea.pylab_plotting_wralea.py_pylab.PyLabPolar[source]#
Make a polar plot. See pylab.polar for details.
- Parameters:
axes – an optional axes where new data will be plotted.
theta (array)
r (array)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve
Multiple theta, r arguments are supported. See
PyLabPlotfor the usage.- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabPsd[source]#
The power spectral density. See pylab.psd for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – input x array
NFFT – The number of data points used in each block for the FFT. The default is 256. Must be even; a power 2 is most efficient.
Fs – The sampling frequency. The default is 2.
Fc – The center frequency of x. Default is 0.
detrend (str) – The function applied to each segment before fft-ing, designed to remove the mean or linear trend (default is ‘none’)
window (str) – function or a vector of length NFFT. default is hanning window To create other window, use the
PyLabWindownode.noverlap – The number of points of overlap between blocks. The default value is 0.
pad_to (int) – The number of points to which the data segment is padded when performing the FFT (default is None)
sides (str) – Specifies which sides of the PSD to return (default is ‘default’).
scale_by_freq (bool) – (default is True)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabQuiver[source]#
Plot a 2-D field of arrows. See pylab.quiver for details.
- Parameters:
axes – an optional axes where new data will be plotted.
X (array) – x coordinates of the arrow locations (2D)
Y (array) – y coordinates of the arrow locations (2D)
U (array) – x components of the arrow vectors
V (array) – y components of the arrow vectors
C (array) – an optional array used to map colors to the arrows
units (str) – arrow units are in multiples of this unit * ‘width’ or ‘height’: the width or height of the axes * ‘dots’ or ‘inches’: pixels or inches, based on the figure dpi * ‘x’, ‘y’, or ‘xy’: X, Y, or sqrt(X^2+Y^2) data units
angles –
‘uv’: the arrow aspect ratio is 1, so that if U*==*V the angle of the arrow on the plot is 45 degrees CCW from the x-axis
’xy’: the arrow points from (x,y) to (x+u, y+v).
array: arbitrary angles may be specified as an array of values in degrees, CCW from the x-axis.
scale (float) – data units per arrow length unit, e.g. m/s per plot width; a smaller scale parameter makes the arrow longer. If None, a simple autoscaling algorithm is used.
width (float) – shaft width in arrow units
headwidth (float) – head width as multiple of shaft width, default is 3
headlength (float) – head length as multiple of shaft width, default is 5
headaxislength (float) – head length at shaft intersection, default is 4.5
minshaft (float) – length below which arrow scales, in units of head length. Do not set this to less than 1. Default is 1
minlength (float) – minimum length as a multiple of shaft width; if an arrow length is less than this, plot a dot (hexagon) of this diameter instead. Default is 1.
pivot (str) – [ ‘tail’ | ‘middle’ | ‘tip’ ] The part of the arrow that is at the grid point.
color (str) –
PolyCollectionfacecolor kwarg. If C has been set, color has no effect.
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabScatter[source]#
Make scatter plot of x versus y. See pylab.scatter for details
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – a x-data array
y (array) – a y-data array
size (array) – size in size^2 (default is 20) or an array of the same length as x and y.
color (str) – can be a single color format string, or a sequence of color specifications of length N, or a sequence of N numbers to be mapped to colors using the cmap and norm specified via kwargs (see below).
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
cmap – a colormap (default jet). See
PyLabColorMapnode.norm – [ None | Normalize ]
matplotlib.colors.Normalizeinstance is used to scale luminance data to 0,1.vmin (float) – used in conjunction with norm to normalize luminance data. If either min or max are None, the min and max of the color array C is used.
vmax (float) – used in conjunction with norm to normalize luminance data. If either vmin or vmax are None, the min and max of the color array C is used.
alpha (float) – The alpha blending value. (default is 1.0)
linewidth (float) – width of a line in points (default is 1)
figure (int) – figure id
- Returns:
The first connector is the current axe.
The second connector is the output of pylab.scatter
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabSemiLogx[source]#
Make a plot with log scaling on x-axis. See pylab.semilogx for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – one or several arrays, or one or several PyLabLine2D objects.
y – one or several arrays, or one or several PyLabLine2D objects.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize (int) – marker size (default is 10)
linestyle (str) – The linestyle of a curve [None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
color (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.kwargs – a
PyLabLine2Dobject to fully tune the lines.figure (int) – figure id
- Returns:
the axes in which the data are plotted.
the output of plot function (line2d)
- Example:
See also
See
PyLabPlotfor details about the x and y connector.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabSemiLogy[source]#
Make a plot with log scaling on y-axis. See pylab.semilogy for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – one or several arrays, or one or several PyLabLine2D objects.
y – one or several arrays, or one or several PyLabLine2D objects.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize (int) – marker size (default is 10)
linestyle (str) – The linestyle of a curve [None | ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
color (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.kwargs – a
PyLabLine2Dobject to fully tune the lines.figure (int) – figure id
- Returns:
the axes in which the data are plotted.
the output of plot function (line2d)
- Example:
See also
See
PyLabPlotfor details about the x and y connector.
- class openalea.pylab_plotting_wralea.py_pylab.PyLabSpecgram[source]#
Compute a spectrogram of data in x. See pylab.specgram for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – the signal to analyse (a 1D- array)
NFFT – The number of data points used in each block for the FFT. The default is 256.
Fs – The sampling frequency. The default is 2.
Fc – The center frequency of x. Default is 0.
detrend – The function applied to each segment before fft-ing, designed to remove the mean or linear trend (default is ‘none’)
window – function or a vector of length NFFT. default is hanning window To create other window, use the
PyLabWindownode.scale_by_freq – (default is True)
noverlap – The number of points of overlap between blocks. The default value is 128.
xextent
cmap – a colormap (default jet). See
PyLabColorMapnode.pad_to – The number of points to which the data segment is padded when performing the FFT. The default is None.
sides – Specifies which sides of the PSD to return. Default is ‘default’.
scale_by_freq – (default is True)
kwargs (dict) – Connect a
PyLabLine2Dto customize the curve.figure (int) – figure id
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabStem[source]#
A stem plot plots vertical lines. See pylab.stem for details.
- Parameters:
axes – an optional axes where new data will be plotted.
x – 1D array
y – 1D array
marker_color – color of the marker
line_color – color of the line
base_color – color of the base line
marker_style (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
line_style
base_style
- Returns:
the axes in which the data are plotted.
the output of errorbar
- Example:
- class openalea.pylab_plotting_wralea.py_pylab.PyLabStep[source]#
Make a step plot. See pylab.step for details.
- Additional keyword args to
step()are the same as those for
plot().
- Parameters:
axes – an optional axes where new data will be plotted.
x (array) – 1D array
y (array) – 1D array
where – [ ‘pre’ | ‘post’ | ‘mid’ ] * If ‘pre’, the interval from x[i] to x[i+1] has level y[i+1] * If ‘post’, that interval has level y[i] * If ‘mid’, the jumps in y occur half-way between the x-values.
marker (str) – a valid matplotlib marker (e.g., [ ‘+’ | ‘*’]).
markersize – (default is 10)
color (str) – a color selected from the list or connected to a
colornode to select any color from the wheel color.figure (int) – figure id
- Returns:
the axes in which the data are plotted.
- Example:
- Additional keyword args to
- class openalea.pylab_plotting_wralea.py_pylab.PyLabXcorr[source]#
Plot the crosscorrelation of x with y. See pylab.xcorr for details.
x and y inputs must be of same length. If N arrays are connected to x, then the y connector expects N arrays as well and the xcross function will be called N times.
- Parameters:
axes – an optional axes where new data will be plotted.
x – the x input data
y – the y input data
maxlags* (int) – a positive integer detailing the number of lags to show. (default None means
lags).normed (bool) – if True, normalize the data by the autocorrelation at 0-th lag.
usevlines – If True,
vlines()rather thanplot()is used to draw vertical lines from the origin to the acorr. Otherwise, the plot style is determined by the kwargs, which areLine2Dproperties. (default True)detrend (str) – apply a linear or mean detrend if not None (default is None)
kwargs – Connect a PyLabLine2D to customize the output.
figure (int) – figure id
- Returns:
The first connector is the current axe.
The second connector is the output of pylab.acorr that is a tuple (lags, c, linecol, b)
See also
in VisuAlea, see pylab/test/acorr composite node.
PyLabAcorr- Example: