当我渲染下面的示例-Rmd时,它看起来像这样(使用Chrome,与Firefox没有什么区别):
这个数字太小了,如果我看看"真实"我需要的图表,高度太小,比例高度 - 宽度更差。
以下是可重现的示例:
---
title: "Untitled"
author: "author"
date: "9 Mai 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Example
Here is a line of text...................................................................................................................................................................................................................................................................
```{r echo=FALSE}
require(visNetwork, quietly = TRUE)
# minimal example
nodes <- data.frame(id = 1:20)
edges <- data.frame(from = sample(c(1:20), 10), to = sample(c(1:20), 10))
visNetwork(nodes, edges, width = "100%", height = "100%") %>%
visNodes() %>%
visOptions(highlightNearest = TRUE) %>%
visInteraction(navigationButtons = TRUE,
dragNodes = FALSE,
dragView = FALSE, zoomView = FALSE) %>%
visEdges(arrows = 'to')
```
Here is another line of text....................................................................................................................................................................................................................................................................
答案 0 :(得分:2)
我希望使用一些块选项修复它,例如out.height
或fig.height
,但出于某种原因,他们不会。
但是,您可以为窗口小部件本身设置固定高度,只需将数字传递给将被解释为像素的height
参数:
```{r echo=FALSE}
require(visNetwork, quietly = TRUE)
# minimal example
nodes <- data.frame(id = 1:20)
edges <- data.frame(from = sample(c(1:20), 10), to = sample(c(1:20), 10))
visNetwork(nodes, edges, width = "100%", height = 700) %>%
visNodes() %>%
visOptions(highlightNearest = TRUE) %>%
visInteraction(navigationButtons = TRUE,
dragNodes = FALSE,
dragView = FALSE, zoomView = FALSE) %>%
visEdges(arrows = 'to')
```