我正在尝试使用rmarkdown
:
---
title: "Test report"
output: pdf_document
always_allow_html: yes
params:
plot: NA
---
```{r, echo=FALSE,message=FALSE, fig.height=4, fig.width=10, fig.show='hold'}
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = ~carat, y = ~price, color = ~carat,
size = ~carat, text = ~paste("Clarity: ", clarity))
```
作为html输出正常工作,但是当它在pdf中时,图表非常小。任何想法如何解决这个问题?
答案 0 :(得分:0)
我遇到了同样的问题,并通过在out.width = "100%"
中添加opts_chunk
来解决:
knitr::opts_chunk$set(
collapse = TRUE,
comment = ">",
out.width = "100%"
)