问题描述
我无法使自己的情节图适合其flexdashboard容器。底部被切断。
请考虑以下建议:
---
title: "Plotly Flexdashboard Conflict"
output:
flexdashboard::flex_dashboard:
source_code: embed
---
Column
---
### In this tab,the plot is pushed out of bonds by the selectize items.
```{r}
library(tidyverse)
library(plotly)
library(gapminder)
library(flexdashboard)
gapminder_highlighted <-
highlight_key(gapminder[1:408,],~country,"Select a country")
gapminder_ggplot <-
gapminder_highlighted %>%
ggplot(aes(x = year,y = lifeExp,group = country),alpha = 0.2) +
geom_line()
gapminder_plotly <- ggplotly(gapminder_ggplot)
highlight(gapminder_plotly,dynamic = T,selectize = T,persistent = T)
```
### Without selectize,all is well. The x axis is visible.
```{r}
gapminder_plotly
```
Column
---
### When plots overflow,flexdashboard is meant to add a scrollbar. E.g.
```{r}
plot(cars)
plot(nhtemp)
plot(cars)
plot(nhtemp)
```
### Although this does not actually work for all elements. E.g. Text generated from code chunks fails to trigger slider addition:
```{r}
cat( rep("Flex is not responsive to text overflow here. ",100) )
print("This line is hidden")
```
输出在此处的Rpubs上,因此您可以查看:https://rpubs.com/kenwosu/661556
第一个gapminder图被选择项推出界限。而且flexdashboard不会像应该触发的那样触发垂直滚动条的添加。
任何帮助将不胜感激!
解决方法
这看起来好点了吗?我将y轴更改为从0开始,它似乎更清晰地显示了。我刚刚在ggplot图的末尾添加了+ expand_limits(y = 0)
。我尝试弄乱 ggplotly(),但看起来是ggplot图形出现了图形问题。
---
title: "Plotly Flexdashboard Conflict"
output:
flexdashboard::flex_dashboard:
source_code: embed
---
Column
---
### In this tab,the plot is pushed out of bonds by the selectize items.
```{r}
library(tidyverse)
library(plotly)
library(gapminder)
library(flexdashboard)
gapminder_highlighted <-
highlight_key(gapminder[1:408,],~country,"Select a country")
gapminder_ggplot <-
gapminder_highlighted %>%
ggplot(aes(x = year,y = lifeExp,group = country),alpha = 0.2) +
geom_line() + expand_limits(y = 0)
gapminder_plotly <- ggplotly(gapminder_ggplot)
highlight(gapminder_plotly,dynamic = T,selectize = T,persistent = T)
```
### Without selectize,all is well. The x axis is visible.
```{r}
gapminder_plotly
```
Column
---
### When plots overflow,flexdashboard is meant to add a scrollbar. E.g.
```{r}
plot(cars)
plot(nhtemp)
plot(cars)
plot(nhtemp)
```
### Although this does not actually work for all elements. E.g. Text generated from code chunks fails to trigger slider addition:
```{r}
cat( rep("Flex is not responsive to text overflow here. ",100) )
print("This line is hidden")
```