AmesimKnowledge

Simple examples

Plot a spider graph

When using the Simulation scripting functions, you can run a simulation, then load the results and get specific variables. This is typically done through the functions amerunsingle, ameloadt, and amegetvar.

In this example it is assumed that 7 criteria are calculated within the model for analysis of its behavior.

The following piece of Python code illustrates the use of these functions:

Copy


# Post-processing the results
Results, Varnames = ameloadt('myModel')
consumption = amegetvar(Results,Varnames,'FX00_1 function of input x')
performance = amegetvar(Results,Varnames,'FX00_2 function of input x')
tipin = amegetvar(Results,Varnames,'FX00_3 function of input x')
tipout = amegetvar(Results,Varnames,'FX00_4 function of input x')
openthrottle = amegetvar(Results,Varnames,'FX00_5 function of input x')
closethrottle = amegetvar(Results,Varnames,'FX00_6 function of input x')
gearchange = amegetvar(Results,Varnames,'FX00_7 function of input x')

Here the variables consumption, performance, tipin, tipout, openthrottle, closethrottle, and gearchange contain all values during the simulation time. You are going to plot a spider graph that shows the final values of all variables.

Procedure

  1. In the main script you first need to define the labels titles and the values that are used.At this step the code is the following:

    Copy`# Post-processing the results Results, Varnames = ameloadt('myModel') consumption = amegetvar(Results,Varnames,'FX00_1 function of input x') performance = amegetvar(Results,Varnames,'FX00_2 function of input x') tipin = amegetvar(Results,Varnames,'FX00_3 function of input x') tipout = amegetvar(Results,Varnames,'FX00_4 function of input x') openthrottle = amegetvar(Results,Varnames,'FX00_5 function of input x') closethrottle = amegetvar(Results,Varnames,'FX00_6 function of input x') gearchange = amegetvar(Results,Varnames,'FX00_7 function of input x')

data_labels = ['Consumption', 'Performance', 'Tip-in', 'Tip-out', 'Wide\nopen throttle', 'Zero\nthrottle', 'Gear change']

data = [consumption[0][0][-1], performance[0][0][-1], tipin[0][0][-1], tipout[0][0][-1], openthrottle[0][0][-1], closethrottle[0][0][-1], gearchange[0][0][-1]]` Note data_labels is the list of the titles of the spider chart axes and data is the list of the values.

  1. Create a new python file and save it as ameplot.py.This file is a new module where you can define different built-in graph display functions. In this example you only define the spider graph.The function is named plotSpider and has as arguments the data and the labels.

    At this step the code is the following: Copy`import amepyplot

def plotSpider(data, labels):`

  1. In the function plotSpider you first create the plot widget PlotWidget(), set the size of the plot window using the function resize(), and access the graph (through firstGraph()).

    Note Here there is only one graph in the plot window however you can define a layout that contains several graphs in the same plot window.

    At this step the code is the following: Copy`import amepyplot

def plotSpider(data, labels): plot = amepyplot.PlotWidget() plot.resize(800, 550) graph = plot.firstGraph()`

  1. Next, you need to create the data items (using Item object) that gather the values, and the curve that is represented by one set of discrete values: Curve1DDiscrete.The display of the curve can be changed using the function changeDisplay and to modify the symbol for the markers, use configureSymbol on the curve display.

    Note For spider graphs, you can also use the Display2DArea to fill the area defined by the curve with color.

    At this step the code is the following: Copy`import amepyplot

def plotSpider(data, labels): plot = amepyplot.PlotWidget() plot.resize(450, 400) graph = plot.firstGraph()

*# Create data*
item = amepyplot.Item(data)

*# Create curve*
curve = amepyplot.Curve1DDiscrete(labels, item)

*# Change the display to use the 2D line*
curve.changeDisplay(amepyplot.Display2DLine(lineThickness=2))

*# Configure the markers*
curve.display().configureSymbol(style=amepyplot.Circle,
                                fill=amepyplot.RadialFill,
                                antialiasing=True,
                                size=2)`
  1. The final step to fully define the function plotSpider is to attach the curve to the graph using the function addCurve. For the spider graph, you need to apply a conversion of the graph (convertToSpider) otherwise the display will be a basic 2D line.

    At this step the code is the following: Copy`import amepyplot

def plotSpider(data, labels): plot = amepyplot.PlotWidget() plot.resize(450, 400) graph = plot.firstGraph()

*# Create data*
item = amepyplot.Item(data)

*# Create curve*
curve = amepyplot.Curve1DDiscrete(labels, item)

*# Change the display to use the 2D line*
curve.changeDisplay(amepyplot.Display2DLine(lineThickness=2))

*# Configure the markers*
curve.display().configureSymbol(style=amepyplot.Circle,
                                fill=amepyplot.RadialFill,
                                antialiasing=True,
                                size=2)

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

*# Convert graph to spider*
graph.convertToSpider()
graph.setDrawingAreaType(amepyplot.GUI.RoundedArea)

*# Configure graph*
graph.configureTitles(showXAxisTitle=False, showTitle=False)
graph.yAxis().setUnitDrawn(False)

plot.show()
return plot`
Note 
 Some functions are used to configure the graph elements such as the drawing area (straight or rounded), the title, and the axes.
  1. Since the function to plot a spider graph is complete you just need to call it from your main script. Remember that you need to import the new module ameplot.

    Copy`... import ameplot from PySide2 import QtWidgets

... ...

# Post-processing the results Results, Varnames = ameloadt('myModel') consumption = amegetvar(Results, Varnames, 'FX00_1 function of input x') performance = amegetvar(Results, Varnames, 'FX00_2 function of input x') tipin = amegetvar(Results, Varnames, 'FX00_3 function of input x') tipout = amegetvar(Results, Varnames, 'FX00_4 function of input x') openthrottle = amegetvar(Results, Varnames, 'FX00_5 function of input x') closethrottle = amegetvar(Results, Varnames, 'FX00_6 function of input x') gearchange = amegetvar(Results, Varnames, 'FX00_7 function of input x')

data_labels = ['Consumption', 'Performance', 'Tip-in', 'Tip-out', 'Wide\nopen throttle', 'Zero\nthrottle', 'Gear change']

data = [consumption[0][0][-1], performance[0][0][-1], tipin[0][0][-1], tipout[0][0][-1], openthrottle[0][0][-1], closethrottle[0][0][-1], gearchange[0][0][-1]]

# Create the application if needed app = QtWidgets.QApplication.instance() if app is None: app = QtWidgets.QApplication([])

# Call the created function plot = ameplot.plotSpider(data, data_labels)

# Start the application app.exec_()`

Results

Using the Plots Python API you are able to display results that are calculated from a standalone scripts. You can create the following curve for instance:

Figure 14: Simcenter Amesim plot window

Note

The function plotSpider returns the plotWidget; you then have access to the graph for further customization.

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