如何将图案添加到饼图R中

时间:2018-02-15 11:16:58

标签: r plotly r-plotly

我用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))’

谢谢!

0 个答案:

没有答案