I have a dataset where each column is a list of occurrences. I would like to plot three columns as three histograms within one figure, but I cannot wrap my head around the AlgebraOfGraphics idioms.
where df is my data source and each of df[:pf], df[:sf], and df[:ISM] is a Vector.
With AlgebraOfGraphics.jl, I’ve tried
using AlgebraOfGraphics
import AlgebraOfGraphics as AoG
data = AoG.data(df)
m = AoG.mapping(:pf => "Plasma frame") +
AoG.mapping(:sf => "Shock frame") +
AoG.mapping(:ISM => "ISM frame")
hist_layer = AoG.histogram()
layer = data * m * hist_layer
The issue I’m having is with labeling each histogram. I know the => Pair syntax labels the axes, but I couldn’t figure out how to add data series labels from the AoG documentation.
The plain label is done via visual(label = "label") but then you have to do the colors yourself. Easier would be to pass your three columns as a vector and then use dims(1) for color, check this tutorial for reference Intro to AoG - V - Alternative input data formats | AlgebraOfGraphics
Hi! Thank you so much! This almost gets to the result I want, except the legend is labeled with CartesianIndex(i,). It’s not picking up that the labels for each series should be the column name
You can do that via renamer like in the tutorial. The dimensions are not automatically named by input columns, because they are not necessarily defined like that. But maybe in the future that could be built in as a convenient shortcut or something