Question
Can I force a ggplot to an A4 word page without changing fig.height, fig.width and dpi parameters?
Given the same ggplot
with two different fig.height/fig.width
chunk header configurations one can see that the outputs look different. The points in Plot 2 are more conjested and the fonts are bigger. For Plot 1 the opposite is the case.
I'm looking for a programmatic solution to produce Plot 1 and keep it in the given A4 boundaries (theoretically I can manually reduce the size when the word doc is open). I'm showing Plot 2 to clarify that adjusting fig.height/fig.width
will not produce the desired output. Also dpi
must be 600
.
---
output:
officedown::rdocx_document:
base_format: "rmarkdown::word_document"
---
# Plot 1
```{r, fig.height = 10, fig.width = 10, echo = FALSE, message = FALSE, dpi = 600}
library(officedown) # 0.3.0
library(ggplot2) # 3.4.2
df <- data.frame(A = sample(1000), B = sample(1000), size = sample(1000))
ggp <- ggplot(data = df, aes(x = A, y = B, size = size)) +
geom_point()
ggp
```
# Plot 2
```{r, fig.height = 7, fig.width = 7, echo = FALSE, message = FALSE, dpi = 600}
ggp
```