plotting multiple graphs #39
-
I want to plot multiple data series in a graph created without import, dt = std::make_sharedData::Dataset(); This works for a single graph, but how do I add more ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
In the demo (
That will show how to place multiple graphs on a canvas. Basically, you create it with grid (e.g., |
Beta Was this translation helpful? Give feedback.
-
OK, I see. You would want one continuous column with ALL the Y data, and then a grouping column that would contain the labels Y1 and Y2 to distinguish the Y1 and Y2 data. And in the X column you would have duplication, where you have a corresponding X value for the Y1 and Y2 values in the Y column. Basically, a "long" dataset instead of a "wide" one. There is a dataset pivoting feature in this library that you can your current dataset you design and turn it into the required wide format. I''ll put example of that in here tonight... |
Beta Was this translation helpful? Give feedback.
-
If you go into "data/pivot.h", there is a
At this point, you can pass |
Beta Was this translation helpful? Give feedback.
-
This article explains this process of "long" datasets in a bit more detail: https://tidyr.tidyverse.org/reference/pivot_longer.html This is basically what this |
Beta Was this translation helpful? Give feedback.
-
Did this answer your question? |
Beta Was this translation helpful? Give feedback.
If you go into "data/pivot.h", there is a
Pivot
object that you can create. With that, you can callPivotLonger()
and pass in the dataset that you have constructed and get back a "long" dataset that you can then use with the line plot.At this point, you can pass
newDataset
to the line plot and specify "X" and "YValues" as the X and Y and "GROUP" as the grouping column. From there, is will create a line for the Y1 values and another line for the Y2 values.