繁体   English   中英

R-Studio ggplot:我的 face_wrap 情节被切断了,我怎样才能使情节更宽?

[英]R-Studio ggplot: my face_wrap plots are cut off, how can I make the plots wider?

我正在尝试使用 ggplot 和 face_wrap 创建 6 个折线图。 然而,这些图总是局促和切断,因此您无法阅读 x 轴标签,而且图表似乎也被切断了。 如何使它们变宽并调整 x 轴的文本以便我可以看到所有内容?

我的地块的图像

这是我到目前为止的代码:

MPO8_marchapril_2020 <- read.csv("~/TU Berlin/3. Semester/MuB/Laermdaten Schoenefeld/MPO8_marchapril_2020.csv", sep=";", stringsAsFactors=TRUE, dec=",")
str(MPO8_marchapril_2020)
library(tidyr)
datagather2=gather(data = MPO8_marchapril_2020, key = "type of measurements", value = "sound pressure levels", -Datum, -Messstelle)
View(datagather2)
library(ggplot2)
ggplot(datagather2, aes(x=Datum,y=`sound pressure levels`, color=`type of measurements`, group=1))+
  geom_line()+
  labs(title="blabla - 2020", x="", y="")+
  theme(plot.title=element_text(size=30, face="plain"), 
        axis.text.x=element_text(size=15, angle=90), 
        axis.text.y=element_text(size=15),
        axis.title.x=element_text(size=25),
        axis.title.y=element_text(size=25))+
  facet_wrap(~`type of measurements`)

非常感谢您的帮助!!

一种方法是打印到 pdf 并指定宽度/高度选项。 然后,您可以使用不同的维度来匹配您的情节。

ggplot(datagather2, aes(x=Datum,y=`sound pressure levels`, color=`type of measurements`, group=1))+
  geom_line()+
  labs(title="blabla - 2020", x="", y="")+
  theme(plot.title=element_text(size=30, face="plain"), 
        axis.text.x=element_text(size=15, angle=90), 
        axis.text.y=element_text(size=15),
        axis.title.x=element_text(size=25),
        axis.title.y=element_text(size=25))+
  facet_wrap(~`type of measurements`) -> plotforpdf

pdf(file = "path.myplotname.pdf", height = 7, width = 12) #default is inches
print(plotforpdf)
dev.off() # close the pdf printer device

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM