The Plot Python API environment in detail
Add annotations
The plot python API allows you to add some annotation objects to graphs to add information. This section explains how to do that.
Figure 10: Annotated graph
GraphOject : the base class
The base class for all the annotation objects is GraphObject. You can consult the reference documentation that presents a hierarchy diagram of the available objects that inherit from this class.
The important information on these objects are:
Linked to a graph: a GraphObject is attached to a specific graph. That is why all these objects need a parent graph to be created. Copy
*# Creation of the blue area* zone = amepyplot.GraphZone(graph)Set a position: you can set the position in the graph coordinates using the function setModelPosition. If an object is placed like this, it will move according to a user zoom / pan / rotate. Copy
*# Fix the y maximum position for the zone* zone.setYModelRange(yMax = 20)Manipulation: among all the GraphObject classes, there are two main categories: the manipulable one (that uses the base class GraphManipulator) and the other one. The manipulable objects can be used for annotation and their manipulation can be prevented using the function avoidManipulation. Copy
*# The blue vertical line is not movable* vLine.avoidManipulation()Associate information: you can add specific data on these objects using the method setUserData. Copy
*# Add information to the blue zone* zone.setUserData("The blue security zone")Retrieve object: you can get an object from its parent graph using the previously associated data. To do so, use the function findObject on the graph. Copy
*# Get the zone object using the parent graph* zone = graph.findObject("The blue security zone")
Here is an example of the creation of the "problem" text in the figure above:
Copy
# Creation of the text
text = amepyplot.GraphText(graph, True)
# Set the text content
text.setText("Problem")
# Set the position of the text
text.setModelPosition(dataX[problemIndex], dataY[problemIndex])
# Set the offset with the position
text.setPixelOffset(-25, -25)
# The the anchor position of the arrow
text.setWidgetAnchor(amepyplot.GUI.BottomRightWAnchor)
# Customize text color
text.setTextColor(QtCore.Qt.red)
# Customize arrow
text.setLineStyle(QtCore.Qt.SolidLine, amepyplot.GUI.ArrowTip)
text.setLineSizeFactor(5)
Note
The GraphText object can use graph anchors to have a "static" position in the drawing area.
Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Plots_Python_API/xid1204684 · retrieved 2026-07-17