在带有tufte主题的Rmarkdown中,当我使用ggplot2时,我看到背景是白色的,并且不能与html文件的背景颜色混合。见下文。在ggplot2中使用透明不会有任何帮助。
有没有办法使背景的ggplot2与背景的html文件的Rmarkdow与塔夫特主题。见下文

发布于 2021-10-05 11:08:39
我没有找到将ggplot的背景设置为100%透明或NULL的方法。但是您可以在ggplot对象的theme中定义plot.background和legend.background,以便它与针织html的样式兼容。例如,在此图中,结果是this render
```{r fig-margin, fig.margin = TRUE, fig.cap = "MPG vs horsepower, colored by transmission.", fig.width=3.5, fig.height=3.5, cache=TRUE, message=FALSE}库(Ggplot2)
mtcars2 <- mtcar
mtcars2$am <- factor(
mtcars$am,labels =c(‘自动’,‘手动’)
)
ggplot(mtcars2,aes(hp,mpg,color = am)) +
geom_point() + geom_smooth() +
主题(legend.position=‘底部’,
plot.background = element_rect(fill = "#fffff8"), legend.background = element_rect(fill = "#fffff8"))我从here获取了.Rmd代码
https://stackoverflow.com/questions/69300187
复制相似问题