'R Plotly -- How to add borders to histogram bars
everyone!
Sorry for the painfully easy question, but I'm stuck.
I am trying to add borders to these histogram bars and am trying to set their thickness with span. Does anyone know how I can do this?
Here is the code:
library(tidyverse)
diamonds %>%
plot_ly( x = ~cut, showlegend = FALSE ) %>%
add_histogram(hoverinfo = "x+y",
hoverlabel = list(font = list(color = "red"), bgcolor = "yellow")) %>%
dplyr::group_by( cut ) %>%
summarise(n = n()) %>%
add_text(
text = ~scales::comma(n), y = ~n,
textposition = "top middle",
cliponaxis = FALSE,
hoverinfo = "none",
)
Any help with this is appreciated. Thank you!
Solution 1:[1]
Based on the documentation (https://plotly.com/r/bar-charts/), specifically the fourth, fifth, and sixth charts down the page, it looks like you can use the keyword argument line like so line = list(color = 'rgb(8,48,107)', width = 1.5) which would set the color and width of the border of the histogram bars.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bcstryker |
