2

我正在使用此代码生成 2 个带有 rmarkdown 的 highchart 对象:

---
title: "Untitled"
output: html_document
---


```{r library_objects, include= FALSE, echo = FALSE}
library(highcharter)
```

```{r objects, include = T, echo = FALSE}
df1 <- data.frame(data = c(2, 4, 6, 10),
                  labels = c("A", "B", "C", "D")
)
df2 <- data.frame(data = c(1, 3, 5, 9),
                  labels = c("Z", "Y", "X", "W")
)
```

```{r charts, include = T, echo = FALSE}
highchart(height = 150, width = 750) %>% 
  hc_add_series(data = df1$data) %>% 
  hc_xAxis(categories = df1$labels)

highchart(height = 150, width = 750) %>% 
  hc_add_series(data = df2$data) %>% 
  hc_xAxis(categories = df2$labels)
```

我怎么能设法在同一水平面上显示它们(一个在左侧,另一个在右侧)?

4

1 回答 1

3

在 highcharter 包中有hw_grid功能。

```{r charts, include = T, echo = FALSE}
h1 <- hchart(rnorm(100))
h2 <- hchart(sample(head(letters), size = 100, prob = 1:6, replace = TRUE))

hw_grid(h1, h2)
```

还有一些其他的包可以制作像trelliscope这样的htmlwidgets网格。也许你想检查它们。

于 2017-03-20T13:16:27.240 回答