如何解决缩小Rmarkdown中C3小部件与周围文本之间的间隙
我想使用library(c3)
在我的rmarkdown文档中包括一个量规图。但是,差距太大:
---
title: "Gauge"
output: html_document
---
# Gauge
Too big gap to the gauge:
```{r,echo = FALSE,message = FALSE}
library(c3)
data.frame(x = 50) %>%
c3() %>%
c3_gauge()
```
This is fine.
这将产生以下输出:
量规上方的空白和文本太大。我该如何减少呢?在height/width
中玩c3
并没有帮助。
在回答@Daniel之后,我玩了几个选项,这与我的初次尝试相反,设置ehitgh确实可以解决问题(更改无花果的高度也是如此)-很奇怪:
---
title: "Gauge"
output: html_document
---
# Gauge
Too big gap to the gauge:
```{r,message = FALSE}
library(c3)
data.frame(x = 50) %>%
c3() %>%
c3_gauge()
```
This is fine.
# Gauge fig.height = 2,height = 200
Too big gap to the gauge:
```{r,message = FALSE,fig.height=2}
library(c3)
data.frame(x = 50) %>%
c3(height = 200) %>%
c3_gauge()
```
This is fine.
# Gauge height = 200
Too big gap to the gauge:
```{r,message = FALSE}
library(c3)
data.frame(x = 50) %>%
c3(height = 200) %>%
c3_gauge()
```
This is fine.
# Gauge fig.height = 2
Too big gap to the gauge:
```{r,fig.height=2}
library(c3)
data.frame(x = 50) %>%
c3() %>%
c3_gauge()
```
This is fine.
解决方法
如果您知道CSS,可以尝试将其添加到Rmarkdown中,就像R块一样,但是由于Webdev知识有限,我无法从inspect元素中获取正确的属性标签。也许这与网页的填充有关
{css echo=FALSE}
.c3-chart {
height: 200px;
}
我也希望再进行一次编辑,希望它可以为您提供帮助。
---
title: "Gauge"
output: html_document
---
# Gauge
Too big gap to the gauge:
```{r,echo = FALSE,message = FALSE,fig.height=2}
library(c3)
data.frame(x = 50) %>%
c3() %>%
c3_gauge()
```
This is fine.
这使空白变小,但文本也变小,但是也许您可以使用它,看看是否可以使用R块中的fig.height
选项找到解决方案
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。