Question

I would like to plot the grouped data I hold in deedle frame.

e.g. starting with:

let fr =
    Frame.ofColumns [
        "name" =?> series [(1, "a"); (2, "b"); (3, "c"); (4, "c"); (5, "c")]
        "data" =?> series [(1, 11.); (2, 12.); (3, 13.); (4, 10.); (5, 7.)]
        "order" =?> series [(1, 1); (2, 1); (3, 1); (4, 2); (5, 3)]
    ]
    |> Frame.groupRowsByString "name"

I would like to somehow pipe this to Chart.Line + Chart.Combine and end up with one plot that will show trends for each of the grouped series.

Is there an out of box solution for this or I need to manually unpack the frame to the list of observations?

Was it helpful?

Solution

Do I understand it correctly that you'd like to draw a line chart for each group based on the name (i.e. one line chart for the name a, one for the name b, etc.)?

In that case, you can use Frame.nest to create a series of frames - the outer series will be indexed by the first part of the index (the name) and the nested frames will contain the values of each group.

Then you can get the observations (group name together with a frame) and plot the values for each group using Chart.Line and then combine the sequence of line charts like this:

fr 
|> Frame.nest
|> Series.observations
|> Seq.map (fun (k, frame) -> Chart.Line(frame?data, Name=k)) 
|> Chart.Combine
|> Chart.WithLegend()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top