omnetpp.scave.ideplot¶
This module is the interface for displaying plots using the IDE’s native
(non-Matplotlib) plotting widgets from chart scripts. The API is intentionally
very close to matplotlib.pyplot: most functions and the parameters they accept
are a subset of pyplot’s interface. If one restricts themselves to a subset of
Matplotlib’s functionality, switching between omnetpp.scave.ideplot and
matplotlib.pyplot in a chart script may be as simple as much as editing the
import statement.
When the API is used outside the context of a native plotting widget (such as
during the run of opp_charttool, or in IDE during image export), the functions
are emulated with Matplotlib.
Note that this module is stateful. It is set up appropriately by the OMNeT++ IDE
or opp_charttool before the chart script is run.
Functions¶
Returns True if the script is running in the context of a native plotting |
|
|
Plot ys versus xs as lines and/or markers. Call |
|
Make a histogram plot. This function adds one histogram to the bar plot; make |
|
Make a bar plot. This function adds one series to the bar plot; make |
|
Sets one property of the native plot widget to the given value. When invoked |
|
Sets several properties of the native plot widget. It is functionally equivalent to |
Returns the list of property names that the native plot widget supports, such as |
|
|
Displays the given warning text in the plot. |
|
Sets the plot title to the given string. |
|
Sets the label of the X-axis to the given string. |
|
Sets the label of the Y-axis to the given string. |
|
Sets the limits of the X-axis. |
|
Sets the limits of the Y-axis. |
|
Sets the scale of the X-axis. Possible values are 'linear' and 'log'. |
|
Sets the scale of the Y-axis. |
|
Sets the current tick locations and labels of the x-axis. |
|
Configure the grid lines. |
|
Place a legend on the axes. |
Module Contents¶
- is_native_plot()[source]¶
Returns True if the script is running in the context of a native plotting widget, and False otherwise.
-
plot(xs, ys, key=
None, label=None, drawstyle=None, linestyle=None, linewidth=None, color=None, marker=None, markersize=None)[source]¶ Plot ys versus xs as lines and/or markers. Call
plotmultiple times to plot multiple sets of data.Parameters:
xs,ys(array-like or scalar): The horizontal / vertical coordinates of the data points.key(string): Identifies the series in the native plot widget.label(string): Series label for the legenddrawstyle(string): Matplotlib draw style (‘default’, ‘steps’, ‘steps-pre’, ‘steps-mid’, ‘steps-post’)linestyle(string): Matplotlib line style (‘-’, ‘–’, ‘-.’, ‘:’, etc)linewidth(float): Line width in pixelscolor(string): Matplotlib color name or abbreviation (‘b’ for blue, ‘g’ for green, etc.)marker(string): Matplotlib marker name (‘.’, ‘,’, ‘o’, ‘x’, ‘+’, etc.)markersize(float): Size of markers in pixels.
-
hist(x, bins, key=
None, density=False, weights=None, cumulative=False, bottom=None, histtype='stepfilled', color=None, label=None, linewidth=None, underflows=0.0, overflows=0.0, minvalue=math.nan, maxvalue=math.nan)[source]¶ Make a histogram plot. This function adds one histogram to the bar plot; make multiple calls to add multiple histograms.
Parameters:
x(array-like): Input values.bins(array-like): Bin edges, including the left edge of the first bin and the right edge of the last bin.key(string): Identifies the series in the native plot widget.density(bool): Seempl.hist().weights(array-like): Weights.cumulative(bool): Seempl.hist().bottom(float): Location of the bottom baseline for bins.histtype(string): Whether to fill the area under the plot. Accepted values are ‘step’ and ‘stepfilled’.color(string): Matplotlib color name or abbreviation (‘b’ for blue, ‘g’ for green, etc.)label(string): Series label for the legendlinewidth(float): Line width in pixelsunderflows,overflows: Number of values / sum of weights outside the histogram bins in both directions.minvalue,maxvalue: The minimum and maximum value, ornanif unknown.
Restrictions:
Overflow bin data (minvalue, maxvalue, underflows, and overflows) is not accepted by
pyplot.hist().The native plot widget only accepts a precomputed histogram (using the trick documented for
pyplot.hist())
-
bar(x, height, width=
0.8, key=None, label=None, color=None, edgecolor=None)[source]¶ Make a bar plot. This function adds one series to the bar plot; make multiple calls to add multiple series.
The bars are positioned at x with the given alignment. Their dimensions are given by width and height. The vertical baseline is bottom (default 0).
Each of x, height, width, and bottom may either be a scalar applying to all bars, or it may be a sequence of length N providing a separate value for each bar.
Parameters:
x(sequence of scalars): The x coordinates of the bars.height(scalar or sequence of scalars): The height(s) of the bars.width(scalar or array-like): The width(s) of the bars.key(string): Identifies the series in the native plot widget.label(string): The label of the series the bars represent.color(string): The fill color of the bars.edgecolor(string): The edge color of the bars.
The native plot implementation has the following restrictions:
widths are automatic (the parameter is ignored)
x coordinates are automatic (values are ignored)
height must be a sequence (cannot be a scalar)
in multiple calls to bar(), the lengths of the height sequence must be equal (i.e. all series must have the same number of values)
the default color is grey (Matplotlib assigns a different color to each series)
- set_property(key, value)[source]¶
Sets one property of the native plot widget to the given value. When invoked outside the context of a native plot widget, the function does nothing.
Parameters:
key(string): Name of the property.value(string): The value to set. If any other type other than a string is passed in, it will be converted to a string.
- set_properties(props)[source]¶
Sets several properties of the native plot widget. It is functionally equivalent to repeatedly calling
set_propertywith the entries of thepropsdictionary. When invoked outside the context of a native plot widget (TODO?), the function does nothing.Parameters:
props(dict): The properties to set.
- get_supported_property_keys()[source]¶
Returns the list of property names that the native plot widget supports, such as ‘Plot.Title’, ‘X.Axis.Max’, and ‘Legend.Display’, among many others.
Note: This method has no equivalent in
pyplot. When the script runs outside the IDE (TODO?), the method returns an empty list.
-
xlim(left=
None, right=None)[source]¶ Sets the limits of the X-axis.
Parameters:
left(float): The left xlim in data coordinates. Passing None leaves the limit unchanged.right(float): The right xlim in data coordinates. Passing None leaves the limit unchanged.
-
ylim(bottom=
None, top=None)[source]¶ Sets the limits of the Y-axis.
Parameters:
bottom(float): The bottom ylim in data coordinates. Passing None leaves the limit unchanged.top(float): The top ylim in data coordinates. Passing None leaves the limit unchanged.
-
xticks(ticks=
None, labels=None, rotation=0)[source]¶ Sets the current tick locations and labels of the x-axis.
Parameters:
ticks(array_like): A list of positions at which ticks should be placed. You can pass an empty list to disable xticks.labels(array_like): A list of explicit labels to place at the given locs.rotation(float): Label rotation in degrees.
-
grid(b=
True, which='major')[source]¶ Configure the grid lines.
Parameters:
b(bool orNone): Whether to show the grid lines.which(‘major’, ‘minor’, or ‘both’): The grid lines to apply the changes to.
-
legend(show=
None, frameon=None, loc=None)[source]¶ Place a legend on the axes.
Parameters:
show(bool orNone): Whether to show the legend. TODO does pyplot have this?frameon(bool orNone): Control whether the legend should be drawn on a patch (frame). Default isNone, which will take the value from the resource file.loc(string orNone): The location of the legend. Possible values are ‘best’, ‘upper right’, ‘upper left’, ‘lower left’, ‘lower right’, ‘right’, ‘center left’, ‘center right’, ‘lower center’, ‘upper center’, ‘center’ (these are the values supported by Matplotlib), plus additionally ‘outside top left’, ‘outside top center’, ‘outside top right’, ‘outside bottom left’, ‘outside bottom center’, ‘outside bottom right’, ‘outside left top’, ‘outside left center’, ‘outside left bottom’, ‘outside right top’, ‘outside right center’, ‘outside right bottom’.