[ Prev | Index | Next ]
Japanese English
Now Loading...
Download
Please download on PC (not smartphone) and extract the ZIP file. Then double-click VCSSL.bat (batch file) to execute for Microsoft® Windows®, or execute VCSSL.jar (JAR file) on the command line for Linux® and other OSes.
For details, see How to Use.
You are free to use and modify this program and material, even for educational or commercial use. » Details

Plotting Arrays on a 2D Graph

This VCSSL program plots the contents of arrays containing coordinate values on a 2D graph. It's a short sample code, making it a good starting point for modification or reuse.

In graph plotting for numerical computations and similar tasks, it’s common to first output coordinate values to a file from a computation program, and then plot them by reading the file. However, writing to and reading from files takes some time, so it can become a bottleneck when you want to create animations.

In such cases, you can achieve faster plotting by directly transferring the coordinate values stored in arrays to the graph software without using files.

» Related Page: 2D Graph Plotting in Java

- Table of Contents -

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.

If you are using Windows, right-click the ZIP file and choose "Properties" from the menu, and enable "Unblock" checkbox at the right-bottom (in the line of "Security") of the properties-window. Otherwise, when you extract the ZIP file or when you execute the software, security warning messages may pop up and the extraction/execution may fail.

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:

VCSSL__Double_Click_This_to_Execute.bat

For Linux, etc.

Execute "VCSSL.jar" on the command-line terminal as follows:

cd <extracted_folder>
java -jar VCSSL.jar

» If the error message about non-availability of "java" command is output...

After Launching

When the program is launched, it starts the 2D graph software and plots the contents of an array filled with calculated coordinate values.

Graph screen

To change the plotted data, modify the part of the code that fills the coordinate arrays (inside the "for" loop).

Code

Now, let's go through the code of this program. It is written in VCSSL.

Full Code

Here is the complete code:


coding UTF-8;

// Required to handle 2D graphs
import tool.Graph2D;


// Prepare sample coordinate arrays to plot
float xData[11];
float yData[11];
for(int i=0; i<=10; i++){
	xData[i] = i;
	yData[i] = xData[i] * xData[i];
}


// Launch the 2D graph
int graph = newGraph2D();

// Plot the coordinate arrays on the 2D graph
setGraph2DData(graph, xData, yData);
ArrayToGraph2D.vcssl

The flow is simple: the first half fills the arrays with sample coordinate values, and the second half plots them on the graph.

First Part

Let's take a look at the beginning of the code:


coding UTF-8;

// Required to handle 2D graphs
import tool.Graph2D;
code/import.vcssl

The line "coding UTF-8;" specifies the character encoding used in the program (you can also use Shift_JIS, etc.). This line is optional, but including it helps prevent character corruption.

The line "import tool.Graph2D;" loads the tool.Graph2D library, which is necessary to work with 2D graphs.

Preparing Sample Coordinate Arrays

Next is the part where the sample coordinate values are stored in arrays:


// Prepare sample coordinate arrays to plot
float xData[11];
float yData[11];
for(int i=0; i<=10; i++){
	xData[i] = i;
	yData[i] = xData[i] * xData[i];
}
code/write.txt

This code creates two arrays, "xData" and "yData", each with 11 elements to store coordinates. It stores 11 coordinate points for the function "y = x * x", for values of x from 0 to 10.

Compared to the previous example that wrote the coordinates to a file assigning values directly to arrays is much faster. This approach is especially useful when you want to animate the graph -- plotting from arrays instead of files results in much smoother performance.

Plotting

Finally, here is the part that plots the prepared data on the 2D graph:


// Launch the 2D graph
int graph = newGraph2D();

// Plot the coordinate arrays on the 2D graph
setGraph2DData(graph, xData, yData);
code/plot.txt

The newGraph2D() function launches the 2D graph software. Each time you call this function, a new graph window is opened and assigned a unique ID number.

For example, if you launch multiple graph windows, they may be assigned IDs like Graph #12, #22, #101, etc. In this case, the ID is stored in the int variable "graph".

Next, the setGraph2DData() function is used to plot the arrays xData and yData on the 2D graph that was just launched. The first argument specifies the graph ID -- the same one received when the graph was started. Even with multiple graphs open, you can specify which one to operate on using the ID.

License

This VCSSL/Vnano code (files with the ".vcssl" or ".vnano" extensions) is released under the CC0 license, effectively placing it in the public domain. If any sample code in C, C++, or Java is included in this article, it is also released under the same terms. You are free to use, modify, or repurpose it as you wish.

* The distribution folder also includes the VCSSL runtime environment, so you can run the program immediately after downloading. The license for the runtime is included in the “License” folder.
(In short, it can be used freely for both commercial and non-commercial purposes, but the developers take no responsibility for any consequences arising from its use.) For details on the files and licenses included in the distribution folder, please refer to "ReadMe.txt".

* The Vnano runtime environment is also available as open-source, so you can embed it in other software if needed. For more information, see here.


Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Japanese English
[ Prev | Index | Next ]
3DGraphPlottingToolforAnimatingDataLoadedfromMultipleFiles

Asimpletoolwhichplots3Danimationgraphsbyloadingmultipledatafiles.
2DGraphPlottingToolforAnimatingDataLoadedfromMultipleFiles

Asimpletoolwhichplots2Danimationgraphsbyloadingmultipledatafiles.
3DGraphToolforPlotting&AnimatingExpressionsoftheFormof"z=f(x,y,t)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"z=f(x,y,t)"tothe3Dgraph,andplaysitasanimation.
2DGraphToolforPlotting&AnimatingExpressionsoftheFormof"y=f(x,t)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"y=f(x,t)"tothe2Dgraph,andplaysitasanimation.
3DGraphToolforPlotting&AnimatingParametricExpressionsoftheFormofx(t),y(t),z(t)

Asimpletoolwhichplotsparametricexpressions(formulas)oftheformofx(t),y(t),z(t)tothe3Dgraph,andplaysitasanimation.
2DGraphToolforPlotting&AnimatingParametricExpressionsoftheFormofx(t)andy(t)

Asimpletoolwhichplotsparametricexpressions(formulas)oftheformofx(t)andy(t)tothe2Dgraph,andplaysitasanimation.
3DGraphToolforPlottingExpressionsoftheFormof"z=f(x,y)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"z=f(x,y)"tothe3Dgraph.
2DGraphToolforPlottingExpressionsoftheFormof"y=f(x)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"y=f(x)"tothe2Dgraph.
Animatinga3DGraphbyContinuouslyPlottingArrays(Surface/MeshPlot)

Explainshowtocreate3Dsurface/meshgraphanimationsbyupdatingarraysovertime.
Animatinga3DGraphbyContinuouslyPlottingArrays(Point/LinePlot)

Explainshowtocreate3Dpoint/linegraphanimationsbyupdatingarraysovertime.
Animatinga2DGraphbyContinuouslyPlottingArrays

Explainshowtocreate2Dgraphanimationsbyupdatingarraysovertime.
PlottingArraysona3DGraph(Surface/MeshPlot)

Explainshowtoplotcoordinatedatastoredinanarrayona3Dsurface/meshgraphwithsamplecode.
PlottingaFileona3DGraph(Surface/MeshPlot)

Explainshowtoplotcoordinatedatafromafileona3Dsurface/meshgraphwithsamplecode.
PlottingArraysona3DGraph(Point/LineGraph)

Explainshowtoplotcoordinatedatastoredinanarrayona3Dgraphwithsamplecode.
PlottingArraysona2DGraph

Explainshowtoplotcoordinatedatastoredinanarrayona2Dgraphwithsamplecode.
PlottingaFileona3DGraph(Point/LineGraph)

Explainshowtoplotcoordinatedatafromafileona3Dgraphwithsamplecode.
PlottingaFileona2DGraph

Explainshowtoplotcoordinatedatafromafileona2Dgraphwithsamplecode.
Index
[ Prev | Index | Next ]
3DGraphPlottingToolforAnimatingDataLoadedfromMultipleFiles

Asimpletoolwhichplots3Danimationgraphsbyloadingmultipledatafiles.
2DGraphPlottingToolforAnimatingDataLoadedfromMultipleFiles

Asimpletoolwhichplots2Danimationgraphsbyloadingmultipledatafiles.
3DGraphToolforPlotting&AnimatingExpressionsoftheFormof"z=f(x,y,t)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"z=f(x,y,t)"tothe3Dgraph,andplaysitasanimation.
2DGraphToolforPlotting&AnimatingExpressionsoftheFormof"y=f(x,t)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"y=f(x,t)"tothe2Dgraph,andplaysitasanimation.
3DGraphToolforPlotting&AnimatingParametricExpressionsoftheFormofx(t),y(t),z(t)

Asimpletoolwhichplotsparametricexpressions(formulas)oftheformofx(t),y(t),z(t)tothe3Dgraph,andplaysitasanimation.
2DGraphToolforPlotting&AnimatingParametricExpressionsoftheFormofx(t)andy(t)

Asimpletoolwhichplotsparametricexpressions(formulas)oftheformofx(t)andy(t)tothe2Dgraph,andplaysitasanimation.
3DGraphToolforPlottingExpressionsoftheFormof"z=f(x,y)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"z=f(x,y)"tothe3Dgraph.
2DGraphToolforPlottingExpressionsoftheFormof"y=f(x)"

Asimpletoolwhichplotstheexpression(formula)oftheformof"y=f(x)"tothe2Dgraph.
Animatinga3DGraphbyContinuouslyPlottingArrays(Surface/MeshPlot)

Explainshowtocreate3Dsurface/meshgraphanimationsbyupdatingarraysovertime.
Animatinga3DGraphbyContinuouslyPlottingArrays(Point/LinePlot)

Explainshowtocreate3Dpoint/linegraphanimationsbyupdatingarraysovertime.
Animatinga2DGraphbyContinuouslyPlottingArrays

Explainshowtocreate2Dgraphanimationsbyupdatingarraysovertime.
PlottingArraysona3DGraph(Surface/MeshPlot)

Explainshowtoplotcoordinatedatastoredinanarrayona3Dsurface/meshgraphwithsamplecode.
PlottingaFileona3DGraph(Surface/MeshPlot)

Explainshowtoplotcoordinatedatafromafileona3Dsurface/meshgraphwithsamplecode.
PlottingArraysona3DGraph(Point/LineGraph)

Explainshowtoplotcoordinatedatastoredinanarrayona3Dgraphwithsamplecode.
PlottingArraysona2DGraph

Explainshowtoplotcoordinatedatastoredinanarrayona2Dgraphwithsamplecode.
PlottingaFileona3DGraph(Point/LineGraph)

Explainshowtoplotcoordinatedatafromafileona3Dgraphwithsamplecode.
PlottingaFileona2DGraph

Explainshowtoplotcoordinatedatafromafileona2Dgraphwithsamplecode.
News From RINEARN
* VCSSL is developed by RINEARN.

Exevalatorv2.4Released—MCPSupportAdded,NowUsableasanAICalculationTool
2025-11-15 - We'vereleasedExevalatorv2.4,ourexpression-evaluationlibrary.Startingwiththisversion,itsupportsMCP,makingitusableasacalculationtoolforAIassistants.

Exevalatorv2.3Released—NowUsablefromPython
2025-11-04 - We'vereleasedExevalatorv2.3.Startingwiththisversion,youcannowuseitfromPython!WithgrowingdemandaroundAItooldevelopmentinmind,wesharethedetailshere.

ExevalatorUpdated—EasyJapaneseLocalizationforErrorMessages
2025-10-31 - Exevalator2.2.2isout.YoucannowlocalizeerrormessagestoJapanesewithasimplecopy-and-paste,andwe'veincludedseveralbugfixesandminorparseradjustments.

InsideRINPnOnline:ArchitectureOverview
2025-10-22 - AninsidelookatthearchitectureoftherecentlylaunchedonlineversionoftheRINPnscientificcalculator.It'sopensource,soyoucanfreelymodifyandreuseittobuildyourownwebcalculator(maybe!).

MeetRINPnOnline:UsetheScientificCalculatorAnywhere,Instantly
2025-10-21 - RINPn,thefreescientificcalculator,nowhasanonlineversionyoucanuseinstantlyinyourbrowser—onbothPCandsmartphones.Readtheannouncementfordetails.

TheVCSSLSupportAIisHere!—RequiresaChatGPTPlusAccountforPracticalPerformance
2025-08-19 - AnewAIassistantfortheVCSSLprogramminglanguageisheretoansweryourquestionsandhelpwithcoding.ThisarticleexplainshowtouseitandshowcasesplentyofrealQ&Aandgeneratedcodeexamples.

EnglishDocumentationforOurSoftwareandVCSSLIsNowNearlyComplete
2025-06-30 - We'rehappytoannouncethatthelarge-scaleexpansionofourEnglishdocumentationwiththesupportofAI—aprojectthatbegantwoyearsago—hasnowreacheditsinitialtargetmilestone.

VCSSL3.4.52Released:EnhancedIntegrationwithExternalProgramsandMore
2025-05-25 - Thisupdateintroducesenhancementstotheexternalprogramintegrationfeatures(e.g.,forrunningC-languageexecutables).Severalotherimprovementsandfixesarealsoincluded.Detailsinside.