hrbrmstr/waffle

Crop plot when using fewer rows

Opened this issue · 0 comments

I reported a space optimization issue on RStudio Forums when using waffle::waffle() in conjunction with flexdashboard::flex_dashboard() . I think the issue stems from the actual plot keeping the same height instead of adjusting based on the number of rows.

Reprex:

---
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(waffle)
```

### Chart A

```{r}
parts <- c(One=80, Two=30, Three=20, Four=10)
waffle(parts, rows=5)
```

### Chart B

```{r}
waffle(parts, rows=5, size = 1)
```

### Chart C

```{r}
waffle(parts, rows=5, size = 4, legend_pos = "bottom")
```

### Chart D

```{r, fig.width = 10, fig.height = 8}
waffle(parts, rows=5)
```

Using a single panel:

A solution would be to automatically crop the plot based on the height of the actual drawing.