RStudio:在一张图中包含多个图

时间:2019-02-16 19:29:48

标签: r

Data1 in Excel

我在RStudio中有以下绘图:

图(Data1 $ Year,Data1 $ UKAll16_64,pch = 16,cex = 0.5,type =“ l”,col =“ blue”,main =“失业率16-64”,xlab =“ YEARS (YR)“,ylab =” PERCENTAGE(%)“)

图(Data1 $ Year,Data1 $ UKFemale16_64,pch = 16,cex = 0.5,type =“ l”,col =“ red”,main =“失业率女性16-64”,xlab =“ YEARS(YR)“,ylab =” PERCENTAGE(%)“)

图(Data1 $ Year,Data1 $ UKMale16_64,pch = 16,cex = 0.5,type =“ l”,col =“ orange”,main =“失业率MALES 16-64”,xlab =“ YEARS(YR)“,ylab =” PERCENTAGE(%)“)


由于我是R和RStudio的新手,所以我仍在学习,并且想知道如何在一张图中包含所有3个。任何帮助将不胜感激!

编辑:我以在excel上想要的形式包含了数据集,以直观的示例说明我要在R Studio上完成的工作

1 个答案:

答案 0 :(得分:0)

只需在第二个和第三个“图”上使用行即可。使用lty更改线型,使用lwd更改线宽。 Cex与绘制线条无关。

plot(Data1$Year, Data1$UKAll16_64, lwd = 0.5,type="l",
     col = "blue", main = "UNEMPLOYMENT RATES 16-64",
     xlab = "YEARS (YR)", ylab = "PERCENTAGE (%)")

lines(Data1$Year, Data1$UKFemale16_64, col = "red", lty = 3, lwd = 2)

lines(Data1$Year, Data1$UKMale16_64, col = "orange", lty = 5, lwd = 3)