I’m trying to set the margins between the pie charts, but now margin
doesn’t work and the pictures overlap each other.
labels <- rep(LETTERS[seq(from = 1, to = 11)],12)
values <- runif(length(labels), min=0, max=1)
group <- letters[seq(from = 1, to = 12)]
row=rep(seq(0,3), each=3)
col=rep(seq(0,2), time=4)
d1 <- data.frame(labels, values, group)
library(plotly)
p <- plot_ly()
for (i in 1:12) {
var = group[i]
d <- d1 %>% filter(group==var)
p <- p %>% add_pie(data=d, labels = ~labels, values = ~values, type = 'pie',
textposition = "outside", textinfo = 'label+percent',
marker = list(colors = ~colors),
sort = F,
domain = list(row = row[i], column = col[i]),
margin = list(b=180, l=180, r=180, t=180) **#doesn't work**
)
}
p <- p %>% layout(title = NULL, showlegend = F,
grid=list(rows=max(row)+1, columns=max(col)+1),
margin = list(b=80, l=80, r=80, t=80), **#doesn't work**
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
p
orca(p, "pie_chart.pdf", scale = 1, width = 1200, height = 1600)
I’ve also tried setting up to use the subplot
function, but none of that works. Also I’ve tried drawing with ggplot2 but can’t set up labels like plotly.
I would like to use plotly to draw the labels without overlapping or ggplot2 to draw the labels like the above illustration.
Thank you in advance for answers.