Problems reseting panel after using force_panelsizes of package gghx4

How can I reset my plot panel after using force_panelsizes of package gghx4 ? Since I have used this function on an ggplot (and decided not to use it) my plotting panel seems to be stuck with the setup caused by this function.

My plots look for example like this before and now (I had to blur some data due to privacy reasons):

The plot on the left is the plot before my manipulation (uses almost the whole page), the second is the plot after I tried to change the plot size. This plot still limited by width and height. Header and Footer are not shown in the picture.

I already reinstalled my R version (4.1.0), R Studio version (2022.02.3), ggplot2 and my latex-version of tinytex. The plots are part of a knitted report. I had to blur some parts due to privacy reasons.

A MRE of the code I'm using (with minimal change in data for privacy reasons and minimal changes in the used margins for the title, caption and x-Axis because of the small plot area - otherwise no bars would have been plotted):

    number_sections: true
classoption: a4paper
geometry: left=2cm,right=1cm,top=1.5cm,bottom=1cm,includeheadfoot
fontsize: 11pt
lang: de
-   \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}

df <- data.frame(cbind(

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

The PDF-Output still looks like the output I made after my manipulation.

I also tried to close the plotting panels with but there is only the NULL device left: `Error in : cannot shut down device 1 (the null device)`

Any ideas of what went wrong?

Any help is really appreciated :))))))))))))))))

Thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.