使用force_panelsizes tovenage gghx4之后重置面板问题
使用force_panelsize gghx4的force_panelsize之后,如何重置绘图面板?由于我已经在ggplot上使用了此功能(并且决定不使用它),我的绘图面板似乎被此功能引起的设置所困扰。
例如,我的情节以前和现在看起来像这样(由于隐私原因,我必须模糊一些数据):
之前
<
a href =“ https://i.sstatic.net/c2omd。 png“ rel =” nofollow noreferrer“>
因此,第一个绘图几乎使用了整个页面,第二个仍然受宽度和高度的限制。
我已经重新安装了我的R版本(4.1.0),R Studio版本(2022.02.3),GGPLOT2和Tinytex的乳胶版本。这些地块是针织报告的一部分。由于隐私原因,我不得不模糊某些部分。
A MRE
我正在使用的代码的示例(由于隐私原因而更改数据的最小变化,并且由于绘图区域很小而使用的标题,标题和X轴的使用边距最小的更改 - 否则不会绘制任何条形):
---
output:
pdf_document:
number_sections: true
classoption: a4paper
geometry: left=2cm,right=1cm,top=1.5cm,bottom=1cm,includeheadfoot
fontsize: 11pt
lang: de
header-includes:
- \usepackage{caption}
- \captionsetup[figure]{font={footnotesize,rm}}
- \captionsetup[table]{font={footnotesize,rm}}
- \usepackage{lastpage}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhf{}
- \fancyhead[R]{\fontsize{9}{11} \selectfont \leftmark}
- \fancyhead[L]{\fontsize{9}{11} \selectfont Spezialauswertung}
- \fancyfoot[R]{\fontsize{9}{0} \selectfont Seite \thepage\ von \pageref{LastPage}}
---
```{r echo=FALSE, warning=FALSE}
library(ggplot2)
df <- data.frame(cbind(
Pop=rep(1:3,8),
Question_Cat=rep(1:8,each=3),
Values=c(84,89,100,92,100,10,82,91,100,26,18,26,76,90,77,52,36,50,83,100,100,72,81,73),
n=c(129,11,19,90,11,19,101,11,19,127,11,19,126,11,18,120,11,7,127,11,19,125,11,19),
sort=rep(1:8,each=3))
)
lab <- c("Question 1","Question 2","Question 3","Question 4","Question 5","Question 6","Question 7","Question 8")
names(lab) <- as.character(1:8)
ggplot(data=df,aes(x=1,y=Values)) +
geom_bar(aes(group=Pop,fill=factor(Pop)),stat="identity",position="dodge") +
facet_wrap(~ sort,nrow=8,labeller=labeller(.default=lab,.multi_line = FALSE)) +
scale_fill_manual(values=c("#5ba755","#ddebf7","#acb9ca"),labels=c("Group 1","Group 2","Group 3")) +
coord_flip() +
ylim(-2,100) +
geom_text(aes(label=paste(round(Values,2),"%"),group=Pop),position = position_dodge(0.9),hjust=-0.4,vjust=0.35,size=rel(2)) +
geom_text(aes(label=paste("n=",n),y=0,group=Pop),position = position_dodge(0.9),hjust=1.2,size=rel(2)) +
theme_classic() +
theme(legend.position = "top", legend.title = element_blank(),legend.text=element_text(size=rel(0.6)),
plot.title = element_text(hjust = 0.5,size=rel(1.1),face="bold",margin=margin(25,0,5,0)),
plot.caption.position="plot",plot.caption = element_text(size=rel(0.7),margin=margin(0,0,0,0)),
strip.text.x = element_text(size=rel(0.8),face="italic",hjust=0),
strip.background = element_blank(),
axis.text.y=element_blank(),
axis.line.y=element_blank(),
axis.ticks.y=element_blank(),axis.title.y=element_blank(),
axis.title.x=element_text(size=rel(0.7),margin=margin(0,0,0,0)),
axis.text.x=element_text(size=rel(0.85),margin=margin(0,0,0,0))) +
guides(fill = guide_legend(reverse = TRUE)) +
ylab("Prozent") +
xlab("") +
labs(title="Some Plot Title here",subtitle="",caption = "Some explanation here")
```
PDF输出看起来像这样(仍然是错误的):
在所有3个输出标题中均未显示。
我还尝试使用dev.off()关闭绘图面板,但只剩下空设备:
dev.off()中的错误:无法关闭设备1(NULL设备)
对出了什么问题的想法?
任何帮助都非常感谢:)))))))))))))))
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论