2

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.

bigreddot
  • 33,642
  • 5
  • 69
  • 122
Bob
  • 1,274
  • 1
  • 13
  • 26
  • I am not seeing legend in the documentation for `ly_hist`. I think your best shot would be using `ly_text` and manually adding a legend. – M-- Apr 25 '18 at 21:34

0 Answers0