Skip to content

How to plot 2 ggplots side by side? #590

Discussion options

You must be logged in to vote

Testing it out, I get a single code chunk above the two plots that are side by side:

# Testing References

```{r}
#| label: fig-TESTING
#| fig-cap: "A test plot."
#| layout: "[1, 1]"
library(ggplot2)
plt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + 
  geom_point(size = 3) + 
  theme_classic()

plt
plt2 <- ggplot(airquality, aes(Wind, Temp)) + 
  geom_point() + 
  theme_classic()

plt2
```

The code above results in this when rendered:

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@jjallaire
Comment options

Answer selected by WillemSleegers
Comment options

You must be logged in to vote
2 replies
@BradyAJohnston
Comment options

@WillemSleegers
Comment options

Comment options

You must be logged in to vote
1 reply
@BradyAJohnston
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants