AmesimKnowledge

The Plot Python API environment in detail

Create a curve

Once you have a plot widget, you need to create a curve to be displayed.

This section shows you how to do this.

Figure 3: Simple 2D curve

Storing the data: the "Item" object

A simple 2D curve is composed of 2 vectors of values: one for the x values, and the other for the y values. The two vectors must have the same size. Use the Item object to store the x and y values.

Here is an example of the creation of two simple items:

Copy


# Creation of the x and y data
dataX = [0, 1, 2, 3, 4, 5]
dataY = [3, 2, 4, 7, 8, 10]

# Creation of the two items
itemX = amepyplot.Item(dataX, title="Time", unit="s")
itemY = amepyplot.Item(dataY, title="Output force", unit="N")

Note

You can store the unit and the title of the data in the item. This information is displayed in the graph (the title of the y item is used as the default title for a 2D curve).

If you retrieve the data from the scripting API, you can use this piece of code to create the items:

Copy


[R, S] = amesim.ameloadvarst(systemName, variableList)
itemX = amepyplot.Item(R[0], S[0])
itemY = amepyplot.Item(R[1], S[1])

Note

The full documentation of the Item object can be found in the Plots Python API Reference.

Create a curve

Once the Item objects are created, you can create the curve. Note that you are able to choose between several types of curve depending on the data you want to visualize:

  • Curve1DDiscrete can be used when the x data are not continuous but discrete (like a list of runs or a list of criteria).

  • Curve2D is the classic 2D curve. The x and y data are assumed to be continuous.

  • Several types of 3D curves like CurveM1D, CurveMatrix or CurveXYZ. These kinds of curve can be displayed in a 2D graph or a 3D graph.

Here is an example of the creation of a 2D curve:

Copy


# Create a 2D curve
curve = amepyplot.Curve2D(itemX, itemY)

Once the curve is created, you need to add it to a graph. You can access to the graph using the methods available on the plot widget. Here is an example that adds the curve to the first graph of the plot widget:

Copy


# Get the first graph of the plot widget
graph = plotWidget.firstGraph()

# Add curve to the graph
graph.addCurve(curve)

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Plots_Python_API/xid1204682 · retrieved 2026-07-17