0

I have created a pie chart using plotly, the pie has 14 parts, I want to distinguish between them, it needs to be in grayscale I have been using grDevices for grey colors but it is hard to see the differences. I thought about adding a pattern/texture to the chart, can anyone help me with the code, please?

This is the code that I have used:

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

Thanks!

MLavoie
  • 9,671
  • 41
  • 36
  • 56
PSmy
  • 11
  • 1
  • 3
  • 1
    Poly, you've used too much `‘ ’`quotes instead of `'`/`"` in your code along with few errors. Do fix and update if possible. – parth Feb 15 '18 at 11:41
  • and in the third line, `n` is not defined – MLavoie Feb 15 '18 at 11:42
  • I am using Rstudio and this code worked liked this but all grey scale hard to see difference – PSmy Feb 15 '18 at 12:42
  • I don't think it's possible to add pattern...but your grey scale seem fine. Or why not use different colors? – MLavoie Feb 15 '18 at 15:19
  • In grey it hard to tell the differences between 14 shades of grey , to save money in publication :) – PSmy Feb 17 '18 at 11:11

0 Answers0