0

我使用 plotly 创建了一个饼图,该饼有 14 个部分,我想区分它们,它需要是灰度的 我一直在使用 grDevices 来表示灰色,但很难看出差异。我想在图表中添加图案/纹理,有人可以帮我写代码吗?

这是我使用的代码:

library(plotly)
library(grDevices)
grey.colors(n, start = 0.3, end = 0.9, gamma = 2.2, alpha = NULL)
A <- c(1426,329,65,62,56,52,45,43,29,24,21,14,13,146)
lbls <- c(A,B,C,D,E,F,G,H,I,J,K,L,M,N)
df= data.frame(A, lbls )
t<- list(family=“Times New Roman”, size=12,color=‘black’)
plot_ly(df, labels = ~lbls,
values = ~A, type = ‘pie’,marker = list(colors = grey.colors,
line = list(color = ‘#0f0e0e’, width = 1)),textfont=t,
textinfo = ‘percent+value’,
hoverinfo = ‘text’,
text = ~paste( A, ’ individuals’),
marker = list(colors = gcolors,
line = list(color = ‘#FFFFFF’, width = 1)))%>%
add_pie(hole=0.0)%>%
layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))’

谢谢!

4

0 回答 0