r - rmarkdown ggplot tufte 主题背景色
问题描述
在Rmarkdown
with tufte 主题中,当我使用 时ggplot2
,我看到背景是白色的,并且不与 html 文件的背景颜色混合。见下文。使用透明的ggplot2
没有帮助。
有没有办法在tufte 主题中使ggplot2
背景与 html 文件的背景混合。Rmarkdow
见下文
解决方案
我没有找到将 ggplot 的背景设置为 100% 透明或 NULL 的方法。但是您可以在 ggplot 对象中定义and plot.background
,使其与 knit'ed html 的样式兼容。例如在这个 ggplot 中,导致这个渲染:legend.background
theme
```{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}
library(ggplot2)
mtcars2 <- mtcars
mtcars2$am <- factor(
mtcars$am, labels = c('automatic', 'manual')
)
ggplot(mtcars2, aes(hp, mpg, color = am)) +
geom_point() + geom_smooth() +
theme(legend.position = 'bottom',
plot.background = element_rect(fill = "#fffff8"),
legend.background = element_rect(fill = "#fffff8"))
```
推荐阅读
- apache-kafka - 为什么 Kafka Streams 似乎需要 ClusterAction 的权限?
- typescript - Mathjax 更新了 Latex 方程的渲染
- javascript - 当产品从购物车中删除时如何更新购物车总摘要
- python - 在 NumPy 中是否有一种矢量化的方式来进行类似矩阵乘法的运算?
- flutter - java接口中是否有等效于flutter的默认方法?
- sql - 在 Oracle 中选择匹配前 10 个 ID 的所有行
- docker - 不同 Elasticseach 镜像的两个 Docker 容器之间的冲突
- c# - 快速更新 OxyPlots(无滑块延迟)
- java - 这个 O(n) 矩阵旋转算法可以在原地完成并保持 O(n) 吗?
- python - 如何在 Axes3D 范围内强制 pcolor 切片的透明度?