问题描述
限时送ChatGPT账号..我们如何在 R 中复制 Tufte 的隐式水平线?
How can we replicate Tufte's implicit horizontal lines in R?
例如,以下是一个很好的起点:
For example, the following is a good starting point:
library(ggplot2)
ggplot(msleep, aes(x=order)) + stat_bin() + theme_bw()
去除边界线应该很简单.关键点,用条形覆盖水平线,我不清楚.
Removing the border line should be straightforward. The crucial point, overlaying the horizontal line with the bars, is unclear to me.
我在这里设想了两种方法:
I imagine two approaches here:
针对此特定示例的临时解决方案建议如何将其合并到主题中推荐答案
@Andrie 答案的补充不是很大,但是您可以利用 ggthemes
包来制作 Tufte-sque 图ggplot2
.下面,我使用 theme_tufte
,使用 extrafont
包更改字体,并使用 opts
微调所有其他视觉功能:
Not a big addition to @Andrie answer, but you can take an advantage of the package ggthemes
to make Tufte-sque plots with ggplot2
. Below, I'm using theme_tufte
, change the font using extrafont
package, and use opts
to fine-tune all the other visual features:
library(ggthemes)
library(extrafont)
ggplot(msleep, aes(x=order)) + stat_bin(width=0.6, fill="gray") +
theme_tufte(base_family="GillSans", base_size=16, ticks=F) +
theme(axis.line=element_blank(), axis.text.x=element_blank(),
axis.title=element_blank()) +
geom_hline(yintercept=seq(5, 20, 5), col="white", lwd=1.2)
这篇关于R 图:创建 Tufte 的水平条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论