Created
November 16, 2022 21:57
-
-
Save jthomasmock/293a5a51ea4f536b6548a8abb1a8f04b to your computer and use it in GitHub Desktop.
Rotating images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
format: html | |
--- | |
```{r} | |
library(ggplot2) | |
library(grid) | |
``` | |
```{r} | |
#| warning: false | |
grid::grid.newpage() | |
p <- ggplot(mtcars, aes(x = disp,y = mpg)) + geom_point() | |
print(p, vp=grid::viewport(angle=-90)) | |
``` | |
```{r} | |
#| echo: fenced | |
#| out-extra: "style='transform: rotate(90deg); margin-top: 75px;'" | |
p | |
``` | |
```{r} | |
#| echo: fenced | |
#| out-extra: 'angle=90' | |
p | |
``` | |
```{r} | |
ggsave("norm-plot.png", p) | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Howdy @Haly-en - as far as I know
out.extra
andout-extra
are arguments passed to CSS/LaTeX layer - while they may work, it might be dependent on LaTeX packaging?I am not at all a LaTeX expert, and there may be LaTeX native methods, you may want to reference: https://latex.org/forum/viewtopic.php?t=9323
Or could rotate the image after saving it on disk with
magick
: