1

当我渲染下面的示例 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....................................................................................................................................................................................................................................................................
4

1 回答 1

2

我希望使用一些块选项来修复它,例如out.heightfig.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')
```

在此处输入图像描述

于 2018-05-09T09:50:42.070 回答