Skip to content

Crop plot when using fewer rows #96

@rempsyc

Description

@rempsyc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions