使用R Markdown在HTML报告中的几个图上滚动

发布于 2025-01-30 13:42:25 字数 698 浏览 3 评论 0原文

使用R MARKDOWN,我想生成一个HTML报告,可以在同一“窗口”中浏览多个图,例如,使用带有两个箭头按钮的滚动条来打印上一个和下一个绘图。我发现了几个问题,询问如何在大数字或图像中滚动,但无法确定在几个图之间滚动的解决方案。 例如,在下面编织RMD代码将在彼此的顶部生成三个图。我应该使用哪种代码使它们滚动?

编辑:我需要一个“单页视图”来轻松比较两个连续的图,即我应该能够以离散而不是连续的方式移动滚动条。

---
title: "Test multiple plots"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Generating multiple plots

I would like these three plots to be at the same location, and to switch between them by pressing buttons or sliding a scroll bar in the html document.

```{r plots, echo = F}
plot(0, pch = 16, col = 1)
plot(0, pch = 16, col = 2)
plot(0, pch = 16, col = 3)
```

感谢您的帮助。

Using R Markdown, I would like to generate an html report where I could browse multiple plots in the same 'window', e.g. using a scrollbar with two arrow buttons to print the previous and next plot. I have found several questions asking how to scroll within a large figure or image, but could not identify a solution to scroll between several plots.
For example, knitting the Rmd code below would generate three graphs on the top of each other. Which code should I use to make them scrollable?

EDIT: I need a 'single page view' to easily compare two consecutive plots, i.e. I should be able to move the scrollbar in a discrete, not continuous, way.

---
title: "Test multiple plots"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Generating multiple plots

I would like these three plots to be at the same location, and to switch between them by pressing buttons or sliding a scroll bar in the html document.

```{r plots, echo = F}
plot(0, pch = 16, col = 1)
plot(0, pch = 16, col = 2)
plot(0, pch = 16, col = 3)
```

Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意中人 2025-02-06 13:42:25

您可以使用以下代码:

---
title: "Test multiple plots"
output: html_document
---

<style>
.vscroll-plot {
    width: 1000px;
    height: 400px;
    overflow-y: scroll;
    overflow-x: hidden;
}
</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(width=200)
```

## Generating multiple plots

I would like these three plots to be at the same location, and to switch between them by pressing buttons or sliding a scroll bar in the html document.

<div class="vscroll-plot">

```{r plots, echo = F}
plot(0, pch = 16, col = 1)
plot(0, pch = 16, col = 2)
plot(0, pch = 16, col = 3)
```

</div>

输出:

”在此处输入图像描述”

您会看到有一个垂直滚动条。您可以更改样式的高度和宽度,以使视图更大或更小。

You can use the following code:

---
title: "Test multiple plots"
output: html_document
---

<style>
.vscroll-plot {
    width: 1000px;
    height: 400px;
    overflow-y: scroll;
    overflow-x: hidden;
}
</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(width=200)
```

## Generating multiple plots

I would like these three plots to be at the same location, and to switch between them by pressing buttons or sliding a scroll bar in the html document.

<div class="vscroll-plot">

```{r plots, echo = F}
plot(0, pch = 16, col = 1)
plot(0, pch = 16, col = 2)
plot(0, pch = 16, col = 3)
```

</div>

Output:

enter image description here

You will see that there is a vertical scrollbar. You can change the height and width in the style to make the view bigger or smaller.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文