PLOTXY - A Scientific Plotting and Post-Processing Program: A Step-By-Step Tutorial
PLOTXY - A Scientific Plotting and Post-Processing Program: A Step-By-Step Tutorial
A step-by-step tutorial
Table of Contents
About this tutorial ................................................................................................................................................................................................................................... 2
What PlotXY is and what can do for you................................................................................................................................................................................................. 2
Getting to know the main windows and giving names to buttons ......................................................................................................................................................... 3
The DataSelection Window 3
The plot window 4
The Fourier chart window 5
Doing the first things: a “real-life” experience ....................................................................................................................................................................................... 6
Doing some activity using the provided files ........................................................................................................................................................................................ 11
Loading a file and doing first things 11
Making, evaluating and managing line plots 13
Looking at data values 15
Zooming and keeping zoomed 17
Special plots: with twin vertical axes or X-Y plots 20
Modifying the plot scales 22
Time shifting 25
Changing the plot type and appearance 26
Exporting selected variables into a new data file 31
Exporting plot into system clipboard or SVG/PNG 31
The “function of variables” feature 32
Creating a Fourier Plot 38
Using several program windows 40
Saving Program State 42
Mark curves to allow clearer B/W printing 42
Printing on paper or pdf 43
Automatic loading of files. 43
Additional information.......................................................................................................................................................................................................................... 43
Customizing the program behaviour 43
Automatic Units of measure and prefixes 44
More on loading files 45
What else? ............................................................................................................................................................................................................................................ 45
Before starting doing things, better is to become acquainted with the three program main windows, and to give names to their buttons.
Main toolbar
SelectedVar
This is the table
VarMenu
Table
Main buttonbox
Abo
Var sorting
button
Keep sc
when plo
Plot Copy
options
Show
Save
Plot data
Add plot Print
title Change
scale markers
Show The plot window
differences
When, in the Data Selection window the plot button is clicked, the plot window is displayed.
It has the appearance shown in the picture aside (in which a simple plot from the supplied file “sample1.adf” is drawn), where names of the toolbar buttons are
also given.
Amplitude
chart
used
time
window
data
cursors
Options, info,
copy and print
buttons
Phase numerical
chart data
Doing the first things: a “real-life” experience
The first thing to do is to load one or more files. Here I show how it works using my own files, just to give ha hint about a real-life experience with the program. In
Working together using the provided files, instead I will propose actions that you can repeat using the sample files provided.
There are two ways of doing this:
1. Using the Load… button
2. Using the drag&drop feature of the operating system: looking at the file name in their own directory, selecting one or more of them, and dragging them
onto the main program window.
Once some files have been loaded the main program window can for instance have the appearance shown below at the left side of the figure (three files) or at
the right side (seven different files).
selected
file
common time
plot1
var-list
When these units of measures are used, also the standard prefixes are used as well (e.g. u for “micro”, m for “milli” k for “kilo”, M for “Mega”, G for “Giga”, etc.).
Now that you have a first idea of how the programs work and how the produced plots look like in a real-life case, let us make together some plots step-by-step
using the enclosed sample files (from sample1.adf to sample3.adf).
Doing some activity using the provided files
If you have gained access to this tutorial, I can assume you have already installed the program
and understood how to launch the program.
However, to launch the program the best way is to use a link you’ve created linking to PlotXY.exe
(that you’ve put in a directory of your choice) and click on it.
When the file is loaded you have two options to load a file (either using the button (Load…) or
dragging a file onto the PlotXY window from the directory where it is.
Once you’ve loaded the program and loaded sample1.adf the program window looks like the one
shown aside.
Since the file is compact and just one, we can reduce the window size to reduce its space
occupation on the screen. To reduce the window size se use the usual way for resizing windows
in computers using the window‘s borders.
Moreover, we choose to display in the file table only one file we click on the Single/multifile
button in the main toolbar
The corresponding windows will now look like as shown aside: the window is
much smaller and saves much of your precious desktop area.
If you have many variables you might find it useful to sort them alphabetically
in ascending or descending order using the Var Sorting button (three pictures
below). When A<->Z is displayed the variables are listed in the same order in
which they appear in their input file.
Note that sorting does not change the number attributed to each variable: for
instance the selected variables remained variables N. 51, 52, 53.
Naturally, if we commonly use small numbers of files and variable and plots, we
want to use small program windows ad default, without having to resize it
anytime we load the program. To do this, we can set the option “remember
windows’ positions and sizes”. The program options are accessed clicking on
the third button from the right in the man toolbar showing a check-mark as
symbol.
Several program options can be set. Here I did show just the one interests us now. Note that the program settings are written as system settings in a region of
the computer storage space the operating system chooses. Under Microsoft Windows it is the Windows’ registry.
Although I don’t advise this ;-) you might want to remove the program from your hard disk and leave the computer completely clean, To do so, you have to open
the program options window and click on the “Reset” button.
In the left window the values are directly shown in the bottom toolbar (time first), while in the right one, because more space is needed, an additional small
window (the data browse window) is created to show the numerical values.
In both cases normally the numbers shown are exactly those present in the inpt file; however, if the “interpolate” box is checked, linear interplation is made
between adjacent points, check sample1.adf file: you will see that corresponding to t=0.0105s the sin(Om*t) value is -0.1563.
The vertical bar can be moved by clicking and dragging using the mouse or using arrow keys on the keboard.
Before using the arrow keys a single click must be done in the plotting area to activate keyboard focus on it.
Left and arrow keys move the bar left and right by one pixel; CTRL+arrow move it by three pixels.
In case you want to see the difference of the values one or more cuves have at different points of time, you can click on the Show differences button. It is located
immediately at right of the show data button, and carries a sign “-“ on it . You will get a second vertical bar such as in the two images below. Whenever you
move the grey bar you get actual values; whenever you move the green one, you will get the differences (difference values are marked with an asterisk “*” at the
left side of the numbers). As before, in case a single plot is shown the numbers are shown in the Plot window, otherwise in a separatate, small additional window.
It might also be useful, in some occasions, to add or remove plots from a plot window without updating the zoom range.
Let us do together an exercise. From rad2.mat we can plot variables 16, 17 and 18. The plot will appear as shown below at left. Then manually zoom between 20
and 40 ms. The resulting plot is shown below at centre.
We might now add or remove curves while leaving the axes range unchanced (between 20 and 40 ms horizontaly, and betweeen – 15 and 15 A).
This is done by clicking on the Keep scale ranges while plotting button (on the main buttonbox of the DataSelection Window) before clicking on the plot button.
If that button is down, the axis scales are left unchanged. Therefore if for instance we remove variable N. 17, and then we plot keeping scales, the plot is as
shown at the rightmost picture below.
Special plots: with twin vertical axes or X-Y plots
Rather often the best visualisation is when two different plots are built using the same horizontal scale but they have different vertical sizes. In these cases it may
be very convenient to realize plot with two different vertical axes (here called twin vertical axes).
PlotXY allows you to create plots with several curves, while allowing you to select which one corresponds to the left vertical axis and which correspond to the
right one.
This can be seen using the enclosed file sample2.mat.
The figures below show what happens if we select a voltage (variable vTas) and a current (iZtriaTap) as variables to be numerically evaluated against the left and
right vertical axes respectively.
The first variable has been selected by left-clicking on its name, the second one right-clinking on its one. In the plot window we can easily understand with
variables refer to the right vertical axis: their name is shown underlined.
Note: You can also right-click on the name of an already selected variable to toggle between left and right vertical axis usage for that variable.
Another useful feature is the possibility to plot a variable against another.
This can be done only from SelectedVars tables were the selected variables come all from the same file. To make X-Y plots:
1. select the variables of interest and
2. click on the “X” column in tie plot var-list of the dataSelection window.
When step 2 is performed, the row onto which one has clicked becomes the “x” variable for X-Y plots. When this step 2 is performed for the first time after the
latest reset of the Plot var-list table the previous x-var is removed from the table, assuming that it represents time, and therefore it is not whished. In case of
subsequent clicks, however, the old X variable is not automatically removed and becomes one of the y variables of the X-Y plot.
Modifying the plot scales
We have seen that PlotXY tries to automatically find the most reasonable and readable scales on the axes. Nevertheless, the user often wants to select min and
max values himself. This can be done clicking on the Change Scale button of the plot window. This will cause the left window below to be displayed:
If one clicks on the ok button, the scales shown in the left plot are used (note, no plot here is visible since I’ve chosen, for this example, a variable that is always
above 2900, this outside the requested Y-axis range).
If “Exact match” is not selected the given Min and Max are still subject to adaptation by the program to ease readability. For instance if one selects min=1 and
Max=2.05 the program will assume a larger span for the axis in such a way that the required span (1,2.05) is contained, but the range can be split in round
segments. In this case the program will assume Min=1, Max=2.2 and intermediate ticmarks will be set every 0.2. If this is done for the vertical axis, the plot will
have the aspect shown in the right picture above. If, however, the user really wants his Min and Max to be shown, he can select Exact match checkbox, and the
situation will be the one shown below:
In this case the ticmark on the vertical axis are in unpleasant positions, but the user request is respected.
From some examples above, the reader might have note that the program tries to show reasonable unit of measure on the axes. For instance variables starting
with “v” are interpreted as being voltage, and the chosen unit of measure is “(V)”. This automatic determination of units of measure has important features, that
are described in detail in section “Automatic Units of measure and prefixes”. Here I just want to say that the user can manually select his axis units of measure,
clicking on the “Units…” button of the “Plot Scale setup” window shown just above here.
When the user clicks on that button, the following Units dialog is displayed.
It allows to select the axis label for an of the three axes. Examples of valid labels are the following ones: (m), (Nm), (N/m 2), (),, m.
Note that exponents can be used, and that the unit of resistance ohm, can correctly be displayed as a Greek uppercase omega.
Time shifting
When comparing curves from different files, especially when they are from measures, it could be useful to time-switching, i.e. horizontally translating them.
Access to time switching is gained by clicking on the “Tmax” cell of the file list table. When this is done, the “Tmax” column changes into the “Tshift” column, and
the background of the cells below becomes lighter (indeed white) to indicate editing possibility, as follows:
To select Tshift values you must first select a cell by clicking on it, then directly write the wanted time-shift value through the keyboard. Or, as an alternative, you
can double click on a cell, and write the wanted time shift or edit the existing value.
You can go back in displaying Tmax instead of Tshift clicking on the cell containing the string “Tshift”.
PLEASE NOTE that currently functions of variables do not take into account the Tshift information.
When you use a log axis, the marks on the axes and gridlines will be at 2x, 4x, 8x the main power of ten.
There are cases in which line plots are not the best way to show a plot. If we want to see only the point read from file we can use General|only dots option. This
is done in the bottom-left plot for the first variable from sample1.adf file.
Finally there are files in which the X-Y correlation is weak; this can be shown using a cloud of points. In this case small squares to show points are too large, and it
is better to use single pixels. This is done in the bottom-right plot, using variable X2 from the MorkSwarm.pl4 file
There are also cases in which instead of line plots the user needs to use a bar chart. This is done in the bottom-left plot (from sample1.df) in full scale, and in the
bottom-right in a zoomed fashion. The bars whose second end falls outside the zooming window are shown greyed..
Finally scales can be linear, log, and dB. Two examples from sample2.mat are shown below
The customisation you do using the Plot Options button are valid for the current plot. The default graphical characteristics of the plots, e.g. those valid when plots
are first created, decided at program level, using the Program options button of the program main window.
The Change scale button allows to manually change axes scales: this allows more flexibility than zooming: you can pan or choose detailed scales. In the bottom-
left plot the variable vDcLoadDcmeno is shown between 0 and 400 V, overriding the default scales.
In the bottom-right zooming on the horizontal axis is made.
Normally the user selected scales in the Plot scale setup dialog are subject to some refining by the scale determination inner engine to allow easy numbers on the
numerical tic marks. If, however the user wants total freedom in choosing minimum and maximum values of an axis, he can attain this checking the Exact match
checkbox. See the example below.
Exporting selected variables into a new data file
Very often files containing output from simulations or measure contain a lot of variables, while only a few of them are of interest for a given purpose.
PlotXY is able to create new files with such a subset of variables. Currently, however, saving only can be made from variables coming from the same input file.
Thus, variables from different files or variables created using The “function of variables” feature, cannot be saved.
To export the selected variables into a new data file chick on the Save vars button of the in the Data Selection window. Currently (May 2016) only adf, Comtrade
and Matlab are available as output formats.
Note that the check-box named “cross-interpolate curves between files” in the current version will always remain unchecked. In the current version of the
program, that disabled checkbox has been introduced to remind the user that no cross-interpolation will be done. This means that the program assumes that in
case of function of variables involving variables from different files, the program assumers that all the samples refer to the same time instants. Necessary (but not
sufficient) for this is that the numbers of points are exactly the same for all the files involved in the same function of variables.
The allowed operators between variables are the following ones: +, -, *, /. As usual, * and / take precedence over + and -. Obviously division requires care, since
there might be division by zero. If division by zero is detected a dialog box will be issued and computation of the function of variable will be stopped.
Valid strings for instance are: “v9-v10”, “2*v1-v2/5”, “V1+1e3*v2”, “1e-3*v1”, “f1v1+f2v2+f1v3”, “v1-(v2+v3)”, “10*v9+20”, “int(v2+v3)”,. The latter example
requests the integral between t=0 and the generic time t of v2+v3.
The first and last strings are used in the examples are shown below. The integral is shown in the same plot along with the function to be integrated for the
maximum clarity.
NOTE. The name of the “function of variable” is just indicated as “f1”, “f2”, etc. However, to ease analysis, if the mouse is left above the variable name shown in
the plot window, a full representation of the formula is shown as a tooltip.
For instance, in in the picture right below the mouse is left on “f1” in the plot window the user will see in a tooltip: “vV1a-vV1b”
In case variables come from different files, the tooltip specifies the file for each variable, as follows:
An example infolving integrals is shown below:
NOTE: integrals are useful to calculate energy flows. For instance int(f*v) and int(u*i) will calculate the mechanical energy and electrical energy if f, v, u, I stand
for force, speed, voltage, current respectively.
Finally consider that also the x variable can be a function of variable. Compare the two plots below:
Creating a Fourier Plot
Electric and sound engineers use a lot Fourier decomposition of periodic waves.
This is well supported by PlotXY.
To make a Fourier plot only a unique variable must be selected. Then, simply click on the “Four” button. The program will try to choose the best parameters for
general usage. In particular it assumes that the simulation, after a possible initial transient has stabilised. Therefore, using the default frequency (that can be
selected by means of the Plot Button of the DataSelection Window) it uses the last period of the available data to make computations.
Take for instance the following pictures, obtained using the supplied rad2.mat file. Here the default frequency is 50 Hz and the simulation goes from zero to 0.06
s, it will use as default the last twenty-millisecond period, for the analysis
Once the chart is shown, you can move around the data cursors to see numerical values in the bottom-right part of the window.
You can zoom the chart. An example is shown below (on the left). The bars that fall into the plot are shown as usually in red (bounded by black rectangles), while
the bars that are higher than the available vertical space are shown greyed.
The fourier Chart can be customised in several ways clicking on the Fourier Options button. The window that appears has the aspect shown above (on the right).
In particular note that the numerical values can be shown in the Fourier Chart window in four different values:
peak of sine components (DC component unchanged)
rms of sine components (DC component unchanged)
all harmonics as a ratio to the DC component value
all harmonics as a ratio to the first harmonic value.
Moreover, if the user clicks on the info button, further data is displayed, e.g.:
𝑥(𝑡) ≅ 𝑋0 + ∑ 𝑋𝑘 sin(𝑘𝜔 + 𝛼𝑘 )
𝑘=1
then:
𝑁 𝑁
1 1
𝑇𝐻𝐷1 = √ ∑ 𝑋𝑘2 𝑇𝐻𝐷0 = √ ∑ 𝑋𝑘2
𝑋1 𝑋0
𝑘=ℎ 𝑘=ℎ
in which h=min(h1,2), and h1 is the minimum value specified in the left edit field below “harmonics to consider” label in the Four options window (in the
displayed example it is zero):
The reason for this choice of h1 should be evident: THD is intended to measure the distortion, i.e. the contribution of unwanted harmonics to the output signal.
Additional information
The units of measure are chosen as a function of the first character of the variable name, according to the following table:
name begins with assumed unit symbol name begins with assumed unit symbol
‘v’ volt V
‘c’ ampere A ‘i’ ampere A
‘p’ power W e energy J
‘t’ time s ‘f’ frequency Hz
Note that the last correspondence is used for horizontal-axis variables only
You can disable this feature unchecking the “autolabel known variables” check box in the Program Options|Plot tab sheet (cf. section Customizing the program
behaviour”)
What else?
In this tutorial you have learnt all the major things you can do with PlotXY. You can learn the rest just by trying.
However, there are specific details on the structure of adf file or the rules that the program use to convert variable names into the supplied formats: for instance
not all the names that are valid as ADF file or pl4 file names can be used as such in matlab files.
This more advanced documentation is provided document: “Input formats and naming conventions.pdf”