如何更改 R 中图形的大小?

问题描述 投票:0回答:1

我制作了一系列饼图,它们的大小需要不同。图像当前扭曲。如何更改尺寸?

x1 <- c(90,7,3)
x2 <- c(70,18,12) 
x3 <- c(17,4,30,17,30) 
label1 <- c('Physically 90%','Spoke 7%','Never 3%')
label2 <- c('Abrupt Stop 70%','Go Around 18%','Stops Far \nAway 12%')
label3 <- c('None 17','Robot-Robot 4%','Robot-\nHuman 30%','Robot-\nObject 17%','Robot-\nSurface 30%')
par(mfrow = c(2,2)) 
pie(x1, label1,main="Instances Where Robot Has Been Stuck", col=rainbow(length(x1)))
pie(x2, label2,main="How Robot Avoids Objects", col=rainbow(length(x2)))
pie(x3, label3,main="Collision Types", col=rainbow(length(x3)))
r xcode graph resize pie-chart
1个回答
0
投票
x1 <- c(90,7,3)
x2 <- c(70,18,12) 
x3 <- c(17,4,30,17,30) 
label1 <- c('Physically 90%','Spoke 7%','Never 3%')
label2 <- c('Abrupt Stop 70%','Go Around 18%','Stops Far \nAway 12%')
label3 <- c('None 17','Robot-Robot 4%','Robot-\nHuman 30%','Robot-\nObject 17%','Robot-\nSurface 30%')
par(mfrow = c(2,2)) 
pie(x1, label1,main="Instances Where Robot Has Been Stuck", col=rainbow(length(x1)), radius=1.05)
pie(x2, label2,main="How Robot Avoids Objects", col=rainbow(length(x2)), radius=1.05)
pie(x3, label3,main="Collision Types", col=rainbow(length(x3)), radius=1.05)

您可以在

pie
中添加参数:
radius=1.05
以调整饼图的大小。

pie 的文档如下:

radius  
the pie is drawn centered in a square box whose sides range from -1−1 to 11. 
If the character strings labeling the slices are long 
it may be necessary to use a smaller radius.

您也可以查看这个帖子: 如何在 R 中使饼图()图表变大而不被切断?

© www.soinside.com 2019 - 2024. All rights reserved.