gpt4 book ai didi

r - 饼图标签被切断

转载 作者:行者123 更新时间:2023-12-01 03:35:51 25 4
gpt4 key购买 nike

我正在制作饼图,有些标签被剪掉了。我想缩小 plotly 以容纳所有标签。下面是一个可重现的示例。

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

最佳答案

你可以试试这个。只需在 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)

关于r - 饼图标签被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35002772/

25 4 0