Splitting slide into two perfect panes and having both outptus show correctly

Hello,

I have the following code. Ideally, I would like to show my graph code on the left hand side on the slide while the output on the right. The default with having things ordered top to bottom is not working well for my needs.

The below is sort of working but items are not really adhering to the width specification. Best way to split slides into dual panels with code and plot?

---
title: "xxx"
author: "xxx"
date: "15/02/2020"
output:
  ioslides_presentation: 
     widescreen: true
  slidy_presentation: default
  powerpoint_presentation: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## 1.1 - 

<style>
.column-left{
  float: left;
  width: 50%;
  text-align: left;
}
.column-right{
  float: left;
  width: 50%;
  text-align: left;
}
</style>
<div class="column-left">
```{r, echo = TRUE, message=FALSE, warning=FALSE}
library(tibble)
library(patchwork)
library(ggplot2)

stack_alpha <- function(N) {
  plot_df <- tibble(
    x       = seq(0.45, 0.55, length.out = N),
    y       = seq(0.45, 0.55, length.out = N), 
    opacity = 0.4
  )
  
  ggplot(plot_df) + 
    geom_tile(aes(x, y, 
                  alpha = I(opacity)), fill = 'black', 
              width=0.5, height = 0.5, colour = NA) + 
    theme_void() + 
    coord_equal()
}

plots <- lapply(1:4, stack_alpha)

patchwork::wrap_plots(plots, ncol = 4)
```
</div>
<div class="column-right">
```{r, echo = FALSE, message=FALSE, warning=FALSE}
library(tibble)
library(patchwork)
library(ggplot2)

stack_alpha <- function(N) {
  plot_df <- tibble(
    x       = seq(0.45, 0.55, length.out = N),
    y       = seq(0.45, 0.55, length.out = N), 
    opacity = 0.4
  )
  
  ggplot(plot_df) + 
    geom_tile(aes(x, y, 
                  alpha = I(opacity)), fill = 'black', 
              width=0.5, height = 0.5, colour = NA) + 
    theme_void() + 
    coord_equal()
}

plots <- lapply(1:4, stack_alpha)

patchwork::wrap_plots(plots, ncol = 4)
```
</div>


Are you aware of this https://evamaerey.github.io/ggplot_flipbook/ggplot_flipbook_xaringan.html#13
?

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