The Plot Python API environment in detail
Create a plot widget
The plot widget is the main object of the API.
This is the first object you need to create in any script to be able to use the API.
Figure 2: Empty plot widget
How to create
Here is a basic example of the creation of the object:
Copy
widget = amepyplot.PlotWidget()
Note
The full documentation of the plot widget object can be found in the Plots Python API Reference
It can be displayed as a top level window or placed inside other widgets. To put it inside another widget (we will call it A), you need to specify that A is the parent of the plot widget. To do this, you can indicate the parent at the creation of the widget like in this example:
Copy
# Creation of a dialog
A = QtWidgets.QDialog()
# Creation of the plot widget as a child of A
widget = amepyplot.PlotWidget(A)
When the plot widget is a child of another widget, you need to use a layout to specify the behavior of the plot widget inside its parent. For example, using a vertical box layout like in the example below, you specify that all the children of the dialog A will be placed one above the other, and every widget will use all the space available horizontally:
Copy
# Creation of the vertical layout on the dialog A
layout = QtWidgets.QVBoxLayout(A)
# Add the plot widget to the layout
layout.addWidget(widget)
Once you have performed these steps, you can display the top level window (whether it is a parent dialog or the plot widget) using the method show. Note that you can also specify the required size:
Copy
# Set the wanted size
A.resize(480, 350)
# Show the main dialog
A.show()
The dialog will be shown when the QApplication will be executed with the line:
Copy
# Start the application
app.exec_()
The plot widget is now displayed like in the figure above.
Note
Inside an App, you can create the plot widget using the App designer (see the advanced example Create a plot in an App).
The abilities of the plot widget
The plot widget will allow you to access to:
The object MenusAndToolBars that allow access to menus and toolbars.
The status bar
The graphs
The plot widget will allow you to:
- Create graph(s). For example, to add a graph in a second row, proceed as follows: Copy`# Add a new row of graph(s) widget.addRow()
# You can access to the new graph graph2 = widget.getGraph(1, 0)`
Create a picture of the widget (method toPixmap). Here is an example of how to save this image on your computer: Copy
*# Export the content of the plot widget to a PNG file* widget.toPixmap().save(r'C:\Data\myImage.png')Update all the graphs (can be useful after the modification of data)
Manage interactions allowed on the graph. By default, the plot widget doesn't allow any modification. If you want to allow some modification, use the method setDefaultInteractions like in this example: Copy
*# Allow to customize curve style (color, line style, thickness...)* widget.setDefaultInteractions(amepyplot.GUI.CurveFormatInteraction)
Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Plots_Python_API/xid1203349 · retrieved 2026-07-17