MC’s PlotXY—A general-purpose plotting and post-processing open-source tool

Abstract MC’s PlotXY, in the following just called PlotXY, is a free piece of software able to make line plots and bar charts from data deriving from measuring devices or simulation programs using several formats. It allows to visualize and post-process these data without the need to have on the target computer the original software that generated it. It was written from the ground-up having researchers and scientists in mind, and therefore is optimized for speed, clarity, soundness. Its special characteristic distinguishing it from the large base of existing plotting software is its flexibility: using this small piece of software, the user can do plotting and post-processing activities on the results obtained from other sources (simulation software or measuring devices) without having these sources installed on the computer where post-processing is made. Moreover, it allows reading file formats rarely available on non-specific software, such as ATP, Comtrade, LabView formats. Although the support of some of these formats is not complete, being the software open-source, anyone can contribute to expanding them, operating on just a single cpp file. It is developed using the Qt platform, which allows good GUI design, and already available for Windows, Macintosh, and Linux systems. This paper describes the software characteristics and some programming techniques used to develop it.


Software metadata Current software version
The software is versioned just mentioning the executable month and year. The version this paper refers to is August 2017 Permanent link to executables of this version http://ceraolo-plotxy.ing.unipi.it/default.htm Legal Software License LGPL 3

Computing platform / Operating System Windows (since XP) and Mac OS (since 10.7-Lion) Several Linux flavors (tested under Ubuntu 16.04) Installation requirements & dependencies
No dependency If available Link to user manual -if formally published include a reference to the publication in the reference list The files available at the link in S2 contain full documentation, as well as a button to fast access the programs tutorial. Support email for questions massimo.ceraolo@unipi.it

Motivation and significance
MC's PlotXY program (in the following simply referred to as PlotXY 1 ) was first built in 1998. It initial motivation was to supply a powerful and easy-to-use plotting program for outputs from the E-mail address: massimo.ceraolo@unipi.it. 1 Other programs that today can be found under ''PlotXY'' name. This paper just describes the one whose full name is ''MC's PlotXY''). freeware ATP program, which at those times had not a satisfactory plotting tool, in the author's opinion. Its first description is now very old [1].
In recent years, it has completely been re-written, using the great power of Qt simulation environment, which, among other things, allows to compile smoothly a program for different platform targets. to output plots in SVG PNG and PDF and to manage modern 4k resolutions and multiple screens.
There are many packages able to do plotting and post-processing today, either commercial or freely distributed. Many of them are programs that in addition to doing numerical computations, have their own plotting routines to show their result, for instance: [2]. This is a powerful and huge commercial program widely used worldwide for scientific computation, and includes sophisticated plotting and post-processing features; • Scilab [3]. This is an open source program able to perform the majority of tasks of Matlab; • Dassault Système's Dymola [4] and OpenModelica [5]. They are tools to simulate models written in Modelica language. Dymola is commercial, OpenModelica is open-source.
• Siemens' Amesim [6]. It is a simulation package, designed to build and simulate models written in a proprietary format, as well as in Modelica language.
• National's LabView [7]. It is a systems engineering software for applications that require test, measurement, and control with rapid access to hardware and data insights. Measured data are written in ascii files having a peculiar format, that allows other pieces of software to read the measured data and accompanying information A specific plotting tool is Gnuplot [8], which is very powerful and distributed for free. But it is oriented to plot mathematical functions and does not make plots from stored data.
Many other plotting/post-processing programs exist, but according to the author's knowledge, they all share characteristics of the previous examples: they are either plotting routines builtin in complex software, in many cases is commercial (such as those in the bullet list above), or routines devoted to mathematical functions plotting.
Typically they support their own proprietary and other formats, but they often lack the capability to understand some exoteric formats such as pl4 outputs from ATP [9] and COMTRADE [10].
None of them is in direct competition with PlotXY, because of its combined features: -It is able to read some exoteric formats such as ATP pl4 and COMTRADE , but also has some support for Mathworks' Matlab [2], National Instruments' LabView [11] and other formats; -it is open-source, and therefore anyone can propose improvements or additions. Indeed the program has been continuously updated even in very recent years following user suggestions -it is very small and portable, does not require the execution of an installation routine, and has a very steep learning curve.
This program however would not be appealing if it lacked the flexibility to use that today is required to visualization programs. It is rich in features that have been developed over the years, which are discussed in the following sections. Another PlotXY-related paper has already appeared [12], which however was just a short communication, and did not consider the most recent development, mainly its conversion from proprietary to open-source code. This paper contains an updated and enhanced program description.

Software philosophy and characteristics
Before showing some examples of plot, here the basic choices behind the proposed software are presented.

GUI
The program has been conceived to be used in conjunction with other pies of software, with a very steep learning curve, on the same computer, at the same time. Therefore the following basic GUI choices were made: • No menus. Carefully chosen commands are fast accessible through push-buttons • Multiple windows, to ease as much as possible share of desktop space with other programs. They can be independently positioned everywhere on the computer desktop; in case of need they can be cleanly arranged clicking on the ''arrange'' button.
• Appearance repeatability across sessions. The user of this program typically selects positions and sizes of all the program widows carefully so that they share desktop space with other programs. These positions and sizes, can be retained from one session to the following one (this is obtained using OS functions such as the MS Windows' registry).

Development platform
GUI programs must access operating systems' Application Program Interface commands, to interact with it with mouse, display, keyboard, timers, etc. This makes normally migrating GUI software from one platform to another very complicated.
Instead, Qt [13] multi-platform programming environment comes with extensive libraries that operate as an intermediate layer between the application software and OS's primitives, and therefore allows the paradigm ''code once, deploy everywhere''. Qt is distributed GPL or LGPL, is very powerful and fast.
PlotXY is currently being compiled under Qt 5.7, but is compatible for compilation with any Qt versions, starting from 5.0. It consists of a of set of .cpp and .h files plus some additional miscellaneous files.
To ease its distribution, it was wished to have in any case a single executable. As a consequence of this, the Windows version is self contained in a ''.exe'' file, the Mac version in an ''app'', the Linux one in an Appimage [14].

Software main capabilities
It has been stated in Section 1 that the basic motivation of this program is to be a free and lean plotting and post-processing program, able to read data from multiple sources, and that this makes it different from the majority of existing other solutions.
All the implemented features were conceived having this idea in mind. These are listed in the following subsections, with come comments about how they are implemented and why.

Plotting capability
PlotXY had the basic features today expected from any plotting program such as possibility to plot signals both versus time or versus other signals, to plot several variables simultaneously taken from the same file or different files, fast multi-layer zoom and unzoom, peeking at numerical values. The user can see either the numbers as read from the input file, or linear interpolated values, if he prefers this.
A special care taken in PlotXY is on the choice of the numbers of axes. PlotXY tries to avoid, whenever possible, numbers containing too many digits on the axes. Much of the code was devoted to this, since some typical way numbers rare shown from other software are not straightforward. This is detailed in Section 4.3.
The program is designed around line plots. However it can also show bar charts, which are very useful to display the output of Fourier analysis.

Input/output capabilities
The idea behind this program requires the capability to read several input formats can be read. Many have been implemented, and the list grows with the help of users that show their needs.
The voluntary way this program is developed, in the past did not allow full support of complex formats; since however the program has recently become open-source, future development of additional input formats can be done with the help of anyone volunteering to do so.
It can also read and write version-4 Matlab files, and read a subset of version-5 format. It would be very easy to make it fully compatible with more recent Matlab versions, but this would imply distributing Mathworks' libraries along with PlotXY executable, which is against its philosophy. The program Matlab reading software, was indeed directly coded in C language.
It can also correctly read any output from two prominent tools to simulate Modelica models, Dymola [4] and OpenModelica [5]. Although official documentation of these file formats does not exist, tests made show full compatibility with any simulation outputs from these tools. Note that Modelica, developed by the non-profit Modelica Association [15] is a fast-growing simulation modeling language, which allows the corresponding models to be simulated virtually with any Modelica-capable tools.
Plots or charts can be copied to clipboard, or saved in PNG, SVG, PDF files. New files containing a selected number of variables among those present in the input files can be created.

Post-processing capability
For a program having the ambition to operating as a useful tool to analyze data from several sources, some post-processing capability is mandatory.
This has been added in a very powerful way, since users can mix curves in a rather arbitrary way: formulas containing sums and/or products of any number of signals, mixing them with constants and using parenthesis are analyzed and plotted. Moreover the integral of input variables or combination of input variables can be created and plotted against time, thus allowing computing energies from powers, stored charges from currents, etc. Some technical details on this are shown in [12].

Speed
Despite the modern development platform, there is still room for good programming techniques.
To plot a line plot on screen it may well happen that some plotting actions are visually redundant. If, for instance several points lie on a straight line, it is sufficient to draw a line from the first up to last point of the straight line, dropping the intermediate ones.
Today, this is partly done directly by development platform libraries. Nevertheless, it is shown in [12], with that the implementation of an original redundant point -elimination routine brought very large time savings, even in comparison with the preprogrammed graphical primitives of Qt platform.

The open source package
The program has recently become an open-source project, made available on GitHub (repository ''max-privato/PlotXY''). Programs created from this repository' source code have the only limitation that they cannot read binary files created from the ATP program [9]. This is because this format is considered an ATP secret.
Binaries including ATP-reading capability are distributed along with this paper, and kept updated in a cloud area whose address is kept updated in the readme.md of the GitHub repository.

Access to files and variables
Since the program is conceived to plot data from different sources, e.g. for comparing simulated and measured data, an easy access to different files, file types and to the list of enclosed variables was pursued.
The left part of Fig. 1, shows several files loaded, with a list of the corresponding basic info on its top, and a list of the variables of the selected one on its bottom-left. By changing the current file the variable list is updated: this allows to create plots comparing signal for different sources. E.g. different files produced by the same program, or files produced by different program, or even comparing measured and simulated data. Two plot examples are shown in the top-right part of the figure.
Basically, PlotXY reads from input files the numerical data to be plotted. However, to be a better Modelica plotting tool, it reads, and tell the users, also the value of parameters i.e., quantities that do not vary during simulation. Parameters are for instance resistances or inductances of a circuit, masses or moments of inertias of mechanical systems, etc. A list of parameters of a Modelica output is shown in the bottom part, corresponding to the simulation reported in file #4 (Rectifier3ph.mat) in the top-left part of Fig. 1.

Plot types
While obviously it is not useful to propose here a comprehensive list of plot features, it is of interest illustrating some special characteristics, and the reasons that have brought to choosing them.

Line plots
Line plots have the usual features of zooming and unzooming, customizing color and line style, adding grids, using log or DB scales, etc., which are usually requires from plotting programs.
Here we discuss only some special features, that not always are present even in good plotting software.
Elimination of visual-redundant-points. When plotting plots with huge number of points it may well happen that some plot segments do not have to be traced on screen, since the correspondent pixels are already set. Avoiding this superfluous drawing can significantly enhance plotting speed. Details of this in [12]. Furthermore, to avoid sluggishness when the plot window is resized, during resizing only a bitmapped image of the displayed plot is resized, which is a very fat operation; the plot is redrawn only when resizing action is finished (i.e. when no resize operation is requested for 100 ms).
Peeking at numerical values. Since PlotXY had scientists and engineers in mind, it shows numerical values exactly as they are taken from the file: linear interpolation is possible, but not mandatory. Users can peek at numerical values either placing the mouse pointer near to curves (individual curve peeking) or moving a ruler with simultaneously shows all the data values corresponding to an individual point on the horizontal axis.
Twin vertical axes. Not all plotting section of simulation programs allow this feature, which is indeed very important when we want to compare curves having different orders of quantities, or even unit of measure X-Y Plots: this allows plotting one variable against another. Some examples on how this feature appears when using PlotXY are shown in Fig. 2, showing time plots (left) the corresponding X-Yplot (middle) as well as a zoomed part of the latter (right).
Bar charts. Fourier analysis of periodic quantities gives rise to discrete values for amplitudes and phases. Nevertheless, it is not uncommon to see these values displayed with line charts, which are confusing. PlotXY, instead, correctly uses bar chart, which include a specific feature to peek at numerical values, zooming capability, etc.

Automatic units of measure and prefixes, smart resizing
Many plotting programs display very large or small numbers in exponential form.
In the upper-left part of Fig. 3, for instance we see how the OpenModelica [5] graphical interface program does this. This is not good technical practice, since all the labels share the same exponent, which is better used just once. Other recent tools share this weakness, such as [4]. PlotXY, instead, adds a unique compact power-of-ten coefficient. When unit of measure is known, either because inferred from the variable name or because specified by the user, the standard prefixes (''µ'', ''m'', ''k'', etc.) are used to make reading even easier. This is for instance shown in the top-right part of Fig. 3, where axes quantities are voltage and time.  When available, unit of measure information is taken from the input file; when this is impossible a convention based on the first letter of variable names can be used.
To have good scalability, the number of tick-marks on the axes must be reduced for small plots and augmented for larger ones. This is done by PlotXY, which uses a variable number of them that can be a minimum of three for tiny plots. Consider for instance the lower-right plots in Fig. 3, which compares the tiniest PlotXY and OpenModelica versions of the plot.

Impact
As discussed in Section 1, PlotXY has a unique set of features that makes it unique in comparison with existing plotting sand post-processing software.
It is open-source, executable (Microsoft's Windows Apple's Mac OS X, and Linux) versions are distributed under LGPL license.
It allows making plots and post-processing data from many different sources, and exporting partial data, and bitmapped or vector-graphics plots. In allows creating multiple plots, with data taken from different sources, for instance simulation or measuring software.
It takes advantage of the state-of-the art Qt development environment, can be useful to scientific and technical users, operating in many technical and scientific fields.