rbokeh, add legend to histogram plot

163 Views Asked by At

I'd like to make a chart with rbokeh that includes three overlapping histograms. I can do this, but no legend appears:

library(rbokeh)

figure(tools=c(), legend_location="top_right", padding_factor = 0.01) %>% 
  ly_hist(rnorm(10000, mean=0), 
          color=color_palette[1], alpha = 0.3, breaks=20, lname="L", legend="L", freq=F) %>%
  ly_hist(rnorm(10000, mean=1, sd=0.25), 
          color=color_palette[2], alpha = 0.3, breaks=20, lname="M", legend="M", freq=F) %>%
  ly_hist(rnorm(10000, mean=2, sd=0.5), 
          color=color_palette[3], alpha = 0.3, breaks=20, lname="H", legend="H", freq=F) 

If I was using base R, I would need to call legend() explicitly, as in Adding key legend to multi-histogram plot in R

I don't see an rbokeh::legend() function.

Can anyone advise how to add a legend to the plot?

Thanks in advance.

0

There are 0 best solutions below