tutorials:plotting-data
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorials:plotting-data [2024/09/27 17:06] – created tim | tutorials:plotting-data [2025/11/01 09:29] (current) – [Visualizing Datasets] Tim | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| GroIMP comes with an included management of dataset and the ability to visualize them, in the following only a small introduction is given. | GroIMP comes with an included management of dataset and the ability to visualize them, in the following only a small introduction is given. | ||
| - | ===== Datasets ===== | + | ===== Datasets |
| A datasets in GroIMP are simple tables, that can be referenced from RGG and the GUI. | 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: | To create a Dataset in GroIMP the DataSetRef object is used as following: | ||
| <code java> | <code java> | ||
| Line 27: | Line 30: | ||
| </ | </ | ||
| - | Alternative | + | It is also possible to create a new row in a dataset in one line of code: |
| - | < | + | < |
| diagram.addRow().set(0, | diagram.addRow().set(0, | ||
| </ | </ | ||
| + | |||
| + | ==== 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(); | ||
| + | </ | ||
| + | |||
| + | ==== Column titles ==== | ||
| + | |||
| + | Similar to the set function it is possible to add column titles using the following command: | ||
| + | |||
| + | <code java > | ||
| + | diagram.setColumnKey(0," | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== 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(" | ||
| + | FileWriter fw = new FileWriter("/ | ||
| + | diagram.export(fw); | ||
| + | fw.close(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | It is also possible to define the Separator that is used for the file by e.g. '' | ||
| + | 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/ | ||
| + | |||
| + | ===== Visualizing Datasets ===== | ||
| + | |||
| + | To visualize a dataset in GroIMP the chart() function is used: | ||
| + | <code java> | ||
| + | | ||
| + | </ | ||
| + | |||
| + | in a full example like this: | ||
| + | |||
| + | <code java Plot_example.rgg> | ||
| + | module A(float len) extends Sphere(0.1) | ||
| + | { | ||
| + | {setShader(GREEN); | ||
| + | } | ||
| + | DatasetRef diagram = new DatasetRef(" | ||
| + | |||
| + | protected void init () | ||
| + | [ | ||
| + | Axiom ==> A(1); | ||
| + | { | ||
| + | diagram.setTitle(" | ||
| + | |||
| + | diagram.clear(); | ||
| + | | ||
| + | chart(diagram, | ||
| + | |||
| + | } | ||
| + | ] | ||
| + | |||
| + | 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, | ||
| + | |||
| + | } | ||
| + | ] | ||
| + | |||
| + | </ | ||
| + | |||
tutorials/plotting-data.1727449580.txt.gz · Last modified: 2024/09/27 17:06 by tim
