For details, see How to Use.
Plotting Arrays on a 3D Graph (Point/Line Graph)
This VCSSL program plots the contents of arrays containing coordinate values on a 3D graph. It's a short sample code, perfect as a base for modifications or reuse.
In graph plotting for numerical computations and similar tasks, it's common to write coordinate values to a file using a calculation program, and then read that file later to plot the data. However, reading and writing files can take time, which becomes a bottleneck when creating animations.
In such cases, you can achieve faster plotting by directly transferring coordinate values stored in arrays to the graph software, without going through files.
» Related page: 3D Graph Plotting in Java
Sponsored Link
How to Use
Download and Extract
At first, click the "Download" button at the above of the title of this page by your PC (not smartphone). A ZIP file will be downloaded.
Then, please extract the ZIP file. On general environment (Windows®, major Linux distributions, etc.), you can extract the ZIP file by selecting "Extract All" and so on from right-clicking menu.
» If the extraction of the downloaded ZIP file is stopped with security warning messages...
Execute this Program
Next, open the extracted folder and execute this VCSSL program.
For Windows
Double-click the following batch file to execute:
For Linux, etc.
Execute "VCSSL.jar" on the command-line terminal as follows:
java -jar VCSSL.jar
» If the error message about non-availability of "java" command is output...
After Launching
When the program is launched, the 3D graph software starts, and the contents of arrays filled with calculated coordinate values are plotted.
To change the plotted data, edit the part of the code that assigns values to the coordinate arrays (inside the "for" loop).
Code
Now, let's go through the code of this program. The code is written in VCSSL.
Full Code
Here is the complete code:
The code first stores sample coordinate values in arrays, and then plots them on the graph.
First Part
Let's look at the first part of the code:
The line "coding UTF-8;" specifies the character encoding of the program. It's not mandatory, but including it helps prevent character corruption.
The line "import tool.Graph3D;" loads the tool.Graph3D library, which is needed to work with 3D graphs.
Preparing Sample Coordinate Arrays
Next is the part where the sample coordinate values are stored in arrays:
This code creates three arrays -- xData, yData, and zData, each with 11 elements -- to store coordinates. It stores 11 points for the functions "y = x * x" and "z = x * y", with x ranging from 0 to 10.
Compared to the method used in Plotting a File on a 3D Graph , where the data was written to a file, assigning values directly to arrays is significantly faster.
This method is especially useful for animating graphs, where writing to files could slow things down -- using arrays enables much smoother plotting.
Plotting
Finally, here is the part that plots the array data on the 3D graph:
The newGraph3D() function launches the 3D graph software. Each time you call this function, a new graph window is launched and assigned a unique ID number.
For example, if you start multiple graph windows, they might be assigned IDs like Graph #12, #22, #101, and so on. Here, the returned ID is stored in the int variable "graph".
Next, the setGraph3DData() function is used to plot the arrays xData, yData, and zData on the 3D graph. The first argument specifies the graph ID received when the graph was launched. Even if multiple graphs are open, you can control each one individually by using its ID.
License
The license of this VCSSL / Vnano code (the file with the extension ".vcssl" / ".vnano") is CC0 (Public Domain), so you can customize / divert / redistribute this VCSSL code freely.
Also, if example code written in C/C++/Java are displayed/distributed on Code section of this page, they also are distributed under CC0, unless otherwise noted.
3D Graph Plotting Tool for Animating Data Loaded from Multiple Files |
|
![]() |
A simple tool which plots 3D animation graphs by loading multiple data files. |
2D Graph Plotting Tool for Animating Data Loaded from Multiple Files |
|
![]() |
A simple tool which plots 2D animation graphs by loading multiple data files. |
3D Graph Tool for Plotting & Animating Expressions of the Form of "z = f(x,y,t)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "z = f(x,y,t)" to the 3D graph, and plays it as animation. |
2D Graph Tool for Plotting & Animating Expressions of the Form of "y = f(x,t)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "y = f(x,t)" to the 2D graph, and plays it as animation. |
3D Graph Tool for Plotting & Animating Parametric Expressions of the Form of x(t), y(t), z(t) |
|
![]() |
A simple tool which plots parametric expressions (formulas) of the form of x(t), y(t), z(t) to the 3D graph, and plays it as animation. |
2D Graph Tool for Plotting & Animating Parametric Expressions of the Form of x(t) and y(t) |
|
![]() |
A simple tool which plots parametric expressions (formulas) of the form of x(t) and y(t) to the 2D graph, and plays it as animation. |
3D Graph Tool for Plotting Expressions of the Form of "z = f(x,y)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "z = f(x,y)" to the 3D graph. |
2D Graph Tool for Plotting Expressions of the Form of "y = f(x)" |
|
![]() |
A simple tool which plots the expression (formula) of the form of "y = f(x)" to the 2D graph. |
Animating a 3D Graph by Continuously Plotting Arrays (Surface/Mesh Plot) |
|
![]() |
Explains how to create 3D surface/mesh graph animations by updating arrays over time. |
Animating a 3D Graph by Continuously Plotting Arrays (Point/Line Plot) |
|
![]() |
Explains how to create 3D point/line graph animations by updating arrays over time. |
Animating a 2D Graph by Continuously Plotting Arrays |
|
![]() |
Explains how to create 2D graph animations by updating arrays over time. |
Plotting Arrays on a 3D Graph (Surface/Mesh Plot) |
|
![]() |
Explains how to plot coordinate data stored in an array on a 3D surface/mesh graph with sample code. |
Plotting a File on a 3D Graph (Surface/Mesh Plot) |
|
![]() |
Explains how to plot coordinate data from a file on a 3D surface/mesh graph with sample code. |
Plotting Arrays on a 3D Graph (Point/Line Graph) |
|
![]() |
Explains how to plot coordinate data stored in an array on a 3D graph with sample code. |
Plotting Arrays on a 2D Graph |
|
![]() |
Explains how to plot coordinate data stored in an array on a 2D graph with sample code. |
Plotting a File on a 3D Graph (Point/Line Graph) |
|
![]() |
Explains how to plot coordinate data from a file on a 3D graph with sample code. |
Plotting a File on a 2D Graph |
|
![]() |
Explains how to plot coordinate data from a file on a 2D graph with sample code. |