Graphing Logging Data with Plotly
What This Sample Can Do
- Graph KV-X logging CSV files in a browser only
- No Python needed
- No server needed
- 2D graph display
- 3D graph display
- Comparing multiple files
Benefits of Using Plotly
- Free to use
- Runs in a browser only
- Zoom and rotation
- 2D/3D graph support
- Easily visualize CSV files
Graphing in a Browser with Plotly
Plotly is an open source graphing library. It can be used from many programming languages such as Python, R and JavaScript
This time I used JavaScript so it can display on a PC alone without a server
(the method here loads it over the network, but you can also download the library and run it locally)
Overview
This shows how to graph data saved to CSV files by the logging function in a browser
The data used is two sine waves and one triangle wave generated every scan and saved by logging
The logging settings are explained on a separate page
2D Graph Example
An example graph of a sine wave
3D Graph Example
An example graph with sine waves on the X and Y axes and a triangle wave on the Z axis, showing a sine wave moving up and down along Z
Logging Settings
Set the devices or variables you want to graph as logging targets
As an example, we log a ladder circuit that outputs phase-shifted sine waves to X and Y and a triangle wave to zz

On the Options tab, check the following items

Graphing with LogGraph.html
Open the downloaded LogGraph.html
This page can load two files and display them in 2D or 3D for comparison
Here only one file is shown
2D display

- Press the [Choose File] button and select the file saved by logging
- In the 2D settings, set the X axis to "DATA No" and the Y axis to "sinwave"
- Press the [2D Display] button to see the logged values of the sinwave variable in the graph below

Change the Y axis to "trianglewave" and press [2D Display] to see that the triangle wave was logged, as shown below

3D graph
- In the 3D settings (FileA), set the X axis to "DATA No", the Y axis to "sinwave" and the Z axis to "coswave"
- Press the 3D Display button to see the logged values in the graph below

Change the X axis to "sinwave", the Y axis to "coswave" and the Z axis to "trianglewave" and press [3D Display] to get the display below

About LogGraph.html
This "LogGraph.html" was created with ChatGPT
If you are interested, copy and paste the HTML of LogGraph.html into ChatGPT and specify what you want to change
Example prompt for having ChatGPT create LogGraph.html
Features of LogGraph.html
- CSV file loading
- 2D graph display
- 3D graph display
- Comparing 2 files
- Axis selection
- Same-scale comparison
- Runs in a browser only
