I'm creating bar graphs in R, and want to add a specific pattern or hatch depending on the value of a specific (binary) feature. Does anyone know of a way to do this in plotly? I've seen it done in ggplot and in python, but not in this case.
Edit: Say the data is plot_data
x_var y_var color_var pattern_var
1 4 name_1 1
2 3 name_2 0
3 6 name_1 0
4 3 name_1 1
5 7 name_2 1
Right now my code for making the plot is:
plot_ly(data = plot_data) %>%
add_bars(
x = ~x_var,
y = ~y_var,
color = ~color_var,
)
so that there are 5 bars of different heights that have two different colors depending on whether they are name_1 or name_2. I want to also have them have a pattern depending on whether pattern_var is 1 or 0, so that if pattern_var is 0, the bar is filled in completely by the color, and if pattern_var is 1, it has stripes or some other pattern.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.