简体   繁体   中英

Change color of plotly graph

I'm creating a graph via Plotly, the type is mesh3d . However, I have a problem. My graph is brown and I can't seem to change it. You can see in my third line, that I specified the color red, however, it has no effect on my graph. Regardless of what I set, the graph is always brown.

graph<- plot_ly(data)%>%
add_trace(x = ~date, y = ~variable, z = ~value, color = ~variable, split=~variable, mode="lines") %>%
add_trace(x = ~date, y = ~variable, z = ~value, type="mesh3d", color = I("white"))

> data
    date variable value
1      2        1  4.36
2      3        1  4.34
3      4        1  4.33
4      7        1  4.34
5      8        1  4.32
6      9        1  4.34
7     10        1  4.32
8     11        1  4.31
9     14        1  4.28
10    15        1  4.23
11    16        1  4.20
12    17        1  4.24
13    18        1  4.19
14    21        1  4.18
...   ...       ..  ....

How do I change the color?

You might want to define your colors in the plot_ly() command. In the case of you maybe wanting a red line:

graph<- plot_ly(data, colors="red")%>%
     add_trace(x = ~date, y = ~variable, z = ~value, color = ~variable, split=~variable, mode="lines") %>%
     add_trace(x = ~date, y = ~variable, z = ~value, type="mesh3d", color = I("white"))

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM