1. Plot GUI

JModelica.org comes with a graphical user interface (GUI) for displaying simulation and / or optimization results. The GUI supports result files generated by JModelica.org and Dymola (both binary and textual formats).

The GUI is located in the module (pyjmi/pyfmi).common.plotting.plot_gui and can be started by Windows users by selecting the shortcut located in the start-menu under JModelica.org. The GUI can also be started by typing the following commands in a Python shell:

from pyjmi.common.plotting import plot_gui   # or pyfmi.common.plotting import plot_gui

Note that the GUI requires the Python package wxPython.

Figure 7.1. Overview of JModelica.org Plot GUI

Overview of JModelica.org Plot GUI

1.1. Introduction

An overview of the GUI is shown in Figure 7.1, “Overview of JModelica.org Plot GUI”. As can be seen, the plot figures are located to the right and can contain multiple figures in various configurations. The left is dedicated to show the loaded result file(s) and corresponding variables together with options for filtering time-varying variables and parameters/constants.

Loading a result file is done using the File menu selection Open which opens a file dialog where either textual (.txt) results or binary (.mat) results can be chosen. The result is then loaded into a tree structure which enables the user to easily browse between components in a model, see Figure 7.2, “A result file has been loaded.” . Multiple results can be loaded either simultaneously or separately by using the File menu option Open repeatedly.

Figure 7.2. A result file has been loaded.

A result file has been loaded.

Displaying trajectories is done by simply checking the box associated with the variable of interest, see Figure 7.3, “Plotting a trajectory.”. Removing a trajectory follows the same principle.

Figure 7.3. Plotting a trajectory.

Plotting a trajectory.

A result can also be removed from the tree view by selecting an item in the tree and by pressing the delete key.

1.2. Edit Options

The GUI allows a range of options, see Figure 7.4, “Figure Options.”, related to how the trajectories are displayed such as line width, color and draw style. Information about a plot can in addition be defined by setting titles and labels. Options related to the figure can be found under the Edit menu as well as adding more plot figures.

Figure 7.4. Figure Options.

Figure Options.

Under Axis/Labels, see Figure 7.5, “Figure Axis and Labels Options.”, options such as defining titles and labels in both X and Y direction can be found together with axis options.

Figure 7.5. Figure Axis and Labels Options.

Figure Axis and Labels Options.

Under Lines/Legends, options for specifying specific line labels and line styles can be found, see Figure 7.6, “Figure Lines and Legends options.”. The top drop-down list contains all variables related to the highlighted figure and the following input fields down to Legend are related to the chosen variable. The changes take effect after the button OK has been pressed. For changing multiple lines in the same session, the Apply button should be used.

Figure 7.6. Figure Lines and Legends options.

Figure Lines and Legends options.

Additional figures can be added from the Add Plot command in the Edit menu. In Figure 7.7, “An additional plot has been added.” an additional figure have been added.

Figure 7.7. An additional plot has been added.

An additional plot has been added.

The figures can be positioned by choosing a figure tab and moving it to one of the borders of the GUI. In Figure 7.8, “Moving Plot Figure.” "Plot 1" have been dragged to the left side of the figure and a highlighted area has emerged which shows where "Plot 1" will be positioned. In Figure 7.9, “GUI after moving the plot window.” the result is shown.

Figure 7.8. Moving Plot Figure.

Moving Plot Figure.

Figure 7.9. GUI after moving the plot window.

GUI after moving the plot window.

If we are to add more figures, an increasingly complex figure layout can be created as is shown in Figure 7.10, “Complex Figure Layout.” where figures also have been dragged to other figure headers.

Figure 7.10. Complex Figure Layout.

Complex Figure Layout.

1.3. View Options

Options for interacting with a figure and changing the display can be found under the View menu. The options are to show/hide a grid, either to use the mouse to move the plot or to use the mouse for zooming and finally to resize the plot to fit the selected variables.

Figure 7.11. Figure View Options.

Figure View Options.

Moving a figure with the move option is performed by simply pressing the left mouse button and while still holding down the button, dragging the plot to the area of interest. A zoom operation is performed in a similar fashion.

1.4. Example

Figure 7.12, “Multiple figure example.” shows an example of how the GUI can be used to plot four different plots with different labels. Some of the lines have also been modified in width and in line style. A grid is also shown.

Figure 7.12. Multiple figure example.

Multiple figure example.