User Tools

Site Tools


02_user_tutorials:plotting:data_plots

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
02_user_tutorials:plotting:data_plots [2025/12/10 13:14] – ↷ Page moved from 02_new_tutorials:plotting:data_plots to 02_user_tutorials:plotting:data_plots gaetan02_user_tutorials:plotting:data_plots [2026/03/20 17:07] (current) – removed Tim
Line 1: Line 1:
-====== Datasets and Plots====== 
- 
-GroIMP comes with an included management of datasets[[01_user_documentation:05_object:04_data:01_dataset|datasets]] and the ability to visualize them, in the following only a small introduction is given.  
- 
-A datasets in GroIMP are simple tables, that can be referenced from RGG and the GUI.  
- 
-==== Getting data in ==== 
- 
-To create a Dataset in GroIMP the DataSetRef object is used as following: 
-<code java> 
-DatasetRef diagram = new DatasetRef("plot"); 
-</code> 
- 
-In a dataset each row is described as a Dataseries and to add data a new series has to be added as following: 
- 
-<code java> 
-Dataseries ds = diagram.addRow(); 
-</code>  
- 
-Now we can add numeric data to the different columns of this series by using the set function: 
-<code java> 
-ds.set(0,1.54); 
-ds.set(1,3); 
-for(int i=2; i<10; i++){ 
- ds.set(i,i+i); 
-} 
-</code> 
- 
-It is also possible to create a new row in a dataset in one line of code: 
-<code java> 
-diagram.addRow().set(0,1).set(1,2); 
-</code> 
- 
-==== Clearing ==== 
- 
-A dataset is a Resource of GroIMP and therefore not removed when the simulation is reset or recompiled. In order to clear a dataset the following command can be used.  
-<code java> 
-diagram.clear(); 
-</code>  
- 
-==== Column titles ==== 
- 
-Similar to the set function it is possible to add column titles using the following command: 
- 
-<code java > 
-diagram.setColumnKey(0,"max(x)").setColumnKey(1,"max(y)").setColumnKey(2,"max(z)"); 
-</code> 
- 
- 
-==== Exporting datasets ==== 
- 
-It is possible to export a dataset from RGG using a Java FileWriter as shown below: 
- 
-<code java> 
-import java.io.FileWriter;  
-public void getData(){ 
- DatasetRef diagram = new DatasetRef("plot"); 
- FileWriter fw = new FileWriter("/home/tim/test.csv");  
- diagram.export(fw); 
- fw.close(); 
-} 
-</code> 
- 
-It is also possible to define the Separator that is used for the file by e.g. ''diagram.export(fw,",");'' 
-And the same works as well  with a StringBuffer instead of the FileWriter. 
- 
-===== Datasets in Gui ===== 
- 
-The datasets can be seen in the dataset explorer. This can be found in the main menu under Panels/Explorers/datasets. Clicking on a dataset opens a very simplistic table view where the data can be seen and also exported. 
- 
-===== Visualizing Datasets ===== 
- 
-To visualize a dataset in GroIMP the chart() function is used: 
-<code java> 
- chart(diagram, XY_PLOT); 
-</code> 
- 
-in a full example like this: 
- 
-<code java> 
-module A(float len) extends Sphere(0.1) 
-{ 
- {setShader(GREEN);} 
-} 
-DatasetRef diagram = new DatasetRef("plot"); 
- 
-protected void init () 
-[ 
- Axiom ==> A(1); 
- { 
- diagram.setTitle("My fancy plot"); 
- 
- diagram.clear(); 
-     diagram.setColumnKey(0,"max(x)").setColumnKey(1,"max(y)").setColumnKey(2,"max(z)"); 
- chart(diagram, XY_PLOT); 
-      
- } 
-] 
- 
-public void run () 
- 
-[ 
- A(x) ==> F(x) [RU(30) RH(90) A(x*0.8)] [RU(-30) RH(90) A(x*0.8)]; 
- { 
- diagram.addRow().set(0,max(location((*A*)).x)).set(1,max(location((*A*)).y)).set(2,max(location((*A*)).z)); 
-  
- }  
-] 
- 
-</code> 
  
02_user_tutorials/plotting/data_plots.1765368852.txt.gz · Last modified: 2025/12/10 13:14 by gaetan