Adding Outlines to plot_ly Histogram

Viewed 965

I'm going through some plot_ly examples and I was surprised to see that the histogram plot does not outline the bars of the histogram.

Here is the code:

x.data <- 1:20

plot_ly(
  x = x.data,
  type="histogram",
  histnorm = "probability",
  nbinsx = 20
)

Which results in this:

I'm looking to have it display similar to this, with visible outlines:

I've looked through the documentation here but can't quite work out how to add outlines to the bars. Any help would be greatly appreciated.

2 Answers

Add bargap = 0.01 in layout to see outlines.

I was trying to find out how to do this in the Python plotly lib for myself and stumbled upon this in the docs. The line property for the histogram is under marker (for some reason?). You can set the line's colour and width from there. I'm afraid I don't know how to do this in R but hopefully the docs help!

Related