我正在制作一个饼图,一些标签被切断了。我想缩小情节以容纳所有标签。以下是可重复的示例。
library(plotly)
plot_ly(type="pie",values=1:19,
labels=c(101:119),textinfo="label+value+percent",
textposition="outside",showlegend=F,marker=list(colors=c(
"gray",
"thistle",
"red",
"lightskyblue",
"deeppink",
"green",
"gold",
"brown",
"purple",
"orange",
"cadetblue",
"darkslategray",
"burlywood",
"yellow",
"skyblue",
"lightgreen",
"hotpink",
"lightgray",
"blue"
)))
答案 0 :(得分:1)
你可以试试这个。只需在layout()表达式中设置边距,高度和宽度即可。只需玩这些数字,直到得到你想要的东西。希望它有所帮助。
m = list(
l = 40,
r = 40,
b = 50,
t = 50,
pad = 0
)
plot_ly(type="pie",values=1:19, height = 25,
labels=c(101:119),textinfo="label+value+percent",
textposition="outside",showlegend=F,marker=list(colors=c(
"gray",
"thistle",
"red",
"lightskyblue",
"deeppink",
"green",
"gold",
"brown",
"purple",
"orange",
"cadetblue",
"darkslategray",
"burlywood",
"yellow",
"skyblue",
"lightgreen",
"hotpink",
"lightgray",
"blue"
))) %>%
layout(autosize = F, width = 800, height = 800, margin = m)