Dymola Basics: 6. Plotting Features

October 17th, 2016 by Mahdieh Mehrabi

Written by: David Briant – Project Engineer

This is the sixth in the Basics of Dymola series following on from the post about the use of the Variable Browser within the simulation window. This post will follow on from that post by expanding on the use of the Variable Browser and other plotting features within the simulation window.

A plotting window can be created by selecting the New Plotting Window button, as highlighted in red in Figure 1. Alternatively, clicking the dropdown menu next to it that allows the user to open either a New Plot Window or a New Table Window. This allows the user to use the variable browser to select variables to plot against either time (default) or another variable. There can be multiple plots displayed within the same window by selecting the New Diagram button to the right of Open New Window, highlighted in blue, which inserts a second plot within the same window


Figure 1: Plotting Window and additional plot within window buttons

In a previous Basics of Dymola post the features of the Variable Browser were described, and how variables can be searched for and filtered after a simulation has been run. Also covered was the ability to use the Difference and Original features within the Advanced tab of the Variable Browser, which allows the difference between selected data to be shown with the original plots hidden.

By default, signals are plotted against time, but they can also be plotted against other variables through the Variable Browser. This is done by right clicking on the desired variable to plot along the x axis, selecting Independent Variable then selecting the path of the variable as shown in Figure 2. This then plots all variables in the selected window against the variable selected. To undo this, right click on any variable within the variable browser and select Independent Variable again and then select Time, ensuring that the desired plot window is active.


Figure 2: Choosing the Independent Variable in the Variable Browser

Plots are automatically resized to fit the data that they are displaying, but if a user needs to investigate a certain area of data in detail then there are several methods of manipulating the displayed data. An area can be enlarged by clicking and dragging on the plot such that the desired area is highlighted, as in Figure 3.


Figure 3: Zooming into an area of the graph using click and drag

To investigate a certain section of the data along either axis, hold the shift button while dragging in the direction of the desired axis; the range of the desired axis will zoom in whilst retaining the other axis range. This can be done across multiple plots within the same window to show the same range in X as long as they have the same X axis as shown in Figure 4.


Figure 4: Zooming into an area of multiple graphs using the shift-click and drag method

Another method of display manipulation is by holding the control button while clicking the plot display. The signal and axis can then be dragged around the plot; holding the control button while using the mouse scroll wheel will zoom in and out of the centre of the plot display.

All of these methods can be undone by using the rescale buttons, found in the same toolbar, as highlighted in red below. Either the active plot within the window with the right rescale button or all the plots can be rescaled to fit within each plot using the left button.


Figure 5: Plotting Toolbar

A user can also plot an expression using the Plot Expression button, highlighted above in green.

The buttons highlighted in blue in Figure 5 remove data from the plots, with the left button clearing the active plot and the right button removing the active plot within a window, if multiple plots exist.

There are additional options that allow the user to change how the data is displayed within a plot, which can be accessed by right clicking on a plot and then selecting Setup to open the Plot Setup menu, as shown in Figure 6. From here the Variable display properties, such as legend name and colour, can be changed for each of the signals in the plot. It also allows modification to the range of the plot in x and y and legend display properties by selecting the relevant tab at the top.


Figure 6: Accessing the Plot Setup window

The display of the data can also be manipulated by right clicking on a selected signal trace or the name of the data in the legend, which brings up the menu shown below. It shows that the colour, line style and which vertical axis the data is displayed on can be varied. If a trace has an associated unit, such as degrees (deg) in the example, the Display Unit menu can be expanded, enabling any units that are of the same type to set as the output. The list can be added to by running an additional display unit function. An example of a function that adds some US imperial units can be found within the Dymola Program files: Program Files (x86)\Dymola 2017\insert\displayunit_us.mos. A user can create an additional function to add any conversions by extending the form and syntax used within the example function. This also adds the unit conversions to the parameter inputs. While inputs and outputs can be changed as above this does not change the raw data of the signal, which should always be in SI units, only how it is displayed in the selected plot. The original unit that is output from the simulation can be found either in the Variable Browser or in the selected variable options of the Variables tab of the Plot Setup window as shown above. Also shown below is the ability to carry out some simple mathematical evaluations on the selected trace by expanding the Signal Operators menu.


Figure 7: Manipulating a data set within the plotting window

There is also the ability to have a Measurement Cursor that can be dragged horizontally, outputting the value of any signal on a plot according to the X axis, in this case time. This can be toggled using the button highlighted in purple in Figure 5. When using time as the dependant variable, there is also the ability to go to a specific time by using the Simulation Time bar as shown below. When changing the time either through dragging the Measurement Cursor or using the Simulation Time bar the animation will also be displayed at the matching time.


Figure 8: Simulation Time Taskbar in simulation window

By: David Briant – Project Engineer