PyChart – A Python module for analysis and visual view of 2D/3D Charts

The paper describes the PyChart module (aimed at analysis and visual view of 2D/3D Charts), which was created with the help of free and Open Source resources, using Python as a programming language and wx.Python as a graphical user interface toolkit. The chart data is imported from a Excel/CSV file with a template structure and is drawn in the PyChart module as XY or XYZ curves similar with Excel scatter with smooth lines and markers style. The main functions of the charts are activated using the toolbar. The module is provided with zooming instruments (fit, pan, zoom in, zoom out), cubic spline curves interpolation, chart intersection with constant X, Y or Z values, visual follow of the 2D chart points to view coordinates, export of data in Windows Clipboard, Excel or Microsoft Word format and saving the chart as a image file.


Introduction
There are some software packages on the market for 2D or 3D curves representation, that can be accesed on-line [1][2][3][4] or as a standalone application [5][6][7][8]. Why create a new package? The answer can be synthesized by the following considerations: o a challenge to create a 2D/3D chart module using only Open Source and free resources; o to obtain an engineering and practical tool for exploring 2D/3D curves; o to intersect 2D / 3D curves with X / Y or X / Y / Z values and obtain numerical intersection coordinates; o to have a module which can be extended with the future necessities or included in other future software.

The software packages
The PyChart software is created with the following free and Open Source resources, Figure 1: o Python -a high-level programming language [9]. Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines. Python is free to use, even for commercial products, because of its OSI-approved open source license. Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python combines o wxPythonis a graphical user interface toolkit (G.U.I.) for the Python programming language [10]. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module (native code) that wraps the popular wxWidgets cross platform G.U.I. library, which is written in C++. Like Python and wxWidgets, wxPython is Open Source which means that it is free for anyone to use and the source code is available for anyone to look at and modify. wxPython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification [11].
o Matplotlibis a comprehensive library for creating static, animated, and interactive visualizations in Python. Its variety of output formats, several chart types, and capability to run interactively or non-interactively makes Matplotlib suitable for use in many different situations [12].
o NumPyis the fundamental package for scientific computing with Python. It contains among other things: a powerful N-dimensional array object, sophisticated functions, tools for integrating C/C++ and Fortran code, useful linear algebra, Fourier transform, and random number capabilities [13].
o SQLiteis a library [14] that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world, with the source code launched in the public domain.

The Input Data Format File
The input data is imported from a Excel or CSV file with the following template structure: o the first line contains the number of curves followed by the chart title, in two cells for the Excel file or separated by a comma in the CSV file; o the second line contains the X and Y labels (for 2D chart) or X, Y and Z labels (for 3D chart) of the chart, in two / three cells for the Excel file or separated by a comma in the CSV file; o a number of lines equal to the number of curves, containing the curve parameter label followed by the number of points of the curve, in two / three cells for the Excel file or separated by a comma in the CSV file; o for every curve, the file format continues with:  one empty line;  a number of lines equal to the number of points of the curve, containing X and Y values (for 2D chart) or X, Y and Z values (for 3D chart) for every point, in two (for 2D chart) or three (for 3D chart) cells for the Excel file or separated by a comma in the CSV file.

The PyChart main window
The PyChart main window is presented in Figure 2 for the 2D chart and in Figure 3 for the 3D chart.
o the application title barcontains the application name, version and name of the loaded file; o the application toolbar-contains icons for the main functions of the application; o the application chart areareserved for the drawing of chart components; o the application status bar -reserved for the application's messages.

The PyChart interface
The PyChart toolbar icons are presented in Table 1. Exit the application 6. The PyChart Data Table  The Data Table window is presented in Figure 4. The toolbar contains icons for exporting the coordinates to Windows clipboard, Microsoft Excel or Microsoft Word, creating a new 2D chart, y=f(x) and x=f(y), based on selected cells.

The PyChart Zooming Tools
The Fit Chart command is activated through the toolbar icon , which is active only for 2D charts. This command places the entire chart area in the current application window.
The Zoom command is activated through the toolbar icon , which is active only for 2D charts. This command shows a chart region defined by two mouse clicks.
The Pan/Zoom command is activated through the toolbar icon , which is active only for 2D charts. This command shows a chart region defined by two mouse clicks. Press the left mouse button and hold it to pan the chart and drag it to a new position; pressing x or y while panning the motion will be constrained to the x or y axis, respectively; press the right mouse button to zoom; the x axis will be zoomed in proportionately to the rightward movement and zoomed out proportionately to the leftward movement.

The PyChart InfoPoints command
The InfoPoints command is activated through the toolbar icon , which is active only for 2D charts. This command will generate a special marker which follows the mouse position by placing the marker to the nearest chart point; also, the status bar will show the ID curve and ID point, the parameter of the curve and X/Y coordinates of the marked point. A middle click mouse will exit the InfoPoints command.

The PyChart Intersect window
The Intersect window is activated through the Intersect toolbar icon, Figure 5. For 2D charts that window is designated to generate the intersection points of the chart with X/Y constant values. To intersect the chart with X or Y values, the option must be selected from the left control list and an input numerical value is required in the associated text control; finally, the Intersect button will calculate the intersection points of the chart with the previous selected value. The Copy button will send the intersection points coordinates to Windows clipboard. The Excel button will send the intersection points coordinates to Microsoft Excel. The Word button will send the intersection points coordinates to Microsoft Word. The Erase button will erase all the previous intersection points from the chart area and coordinate's table. The Quit button hides the Intersect window. The coordinate's table shows the ID, the intersected curve's parameter and the X/Y coordinates of the intersections points. The points resulted from the intersections are marked with distinct colour in the chart area. The values of the intersection points are calculated by cubic spline interpolations functions; the number of founded intersections points is placed on the title bar of the Intersect window.
For 3D charts another window is designated to generate the intersection points of the chart with X/Y/Z constant values, Figure 6. To intersect the chart with X, Y or Z values, the corresponding control must be selected and an input numerical value is required in the text control; finally, the Intersect button will calculate the intersection points of the chart with the previous selected value. The points resulted from the intersections are marked with distinct colour in the chart area and the curve passing through this points will be drawn.   Python was the chosen programming language to create the application. The wxPython module was used to create the frames and all Windows controls: toolbar, individuals controls (text, buttons, lists, etc.). Python is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python doesn't come prepackaged with Windows. It's not quite a simple task to install the desired version together with required dependencies; the easy way is to use the "Python(x,y)" package, a free scientific and engineering development software for numerical computations, data analysis and data visualization based on the Python programming language. The download file is "Python(x,y)-2.7.10.0.exe" with a 808 MB size [15].
The application was written in UliPad, a free wxPython powered, programmer oriented and flexible editor, with many features such as class browser, code auto-complete, HTML viewer, directory browser, wizard and many others [16].
The SQLite module was used to create a database to store additional elements of the software: icon images, help file contents, text files, additional image files. To manage the application database the SQLite Expert was used [17], a powerful visual tool that enables to easily administer the SQLite databases. SQLite Expert integrates database management and maintenance into a single, seamless environment, with a clear and intuitive user interface.