这个问题有两个部分,一个是一般性的,另一个是具体的情况:
set scheme economist。ggplot2中)来生成类似于下面示例的组条图、带有粗体线条的彩色标记(左面板)或矩形置信区间(右面板)?

发布于 2020-04-12 09:58:30
是的,您在ggthemes (ggplot2的扩展)中有theme_economist和theme_economist_white。
对于条形图,您需要使用geom_bar和coord_flip (这里)。
ggthemes (这里)中的示例
library("ggplot2")
library("ggthemes")
p <- ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
facet_wrap(~am) +
# Economist puts x-axis labels on the right-hand side
scale_y_continuous(position = "right")
## Standard
p + theme_economist() +
scale_colour_economist()

## White
p + theme_economist_white() +
scale_colour_economist()

如何再现给出的情节
由于我无法在我的计算机中安装SciencesPo包,所以我建议您使用ggplot + ggthemes方法。
一个很好的起点可能是以下方法。我以diamond数据集为例。
library(dplyr)
library(ggplot2)
library(ggthemes)
df <- diamonds %>%
group_by(cut) %>%
summarise(mean = mean(price), sigma = sd(price),
n = n())
df <- df %>%
mutate(int_minus = mean - 1.96*sigma/sqrt(n),
int_plus = mean + 1.96*sigma/sqrt(n))然后是情节
ggplot(df) +
geom_segment(aes(x = int_minus, xend = int_plus, y = factor(cut), yend = factor(cut)), size = 2L, alpha = 0.4) +
geom_point(aes(x = mean, y = factor(cut)), shape = 15, color = "blue", size = 4L) +
theme_economist_white()

https://stackoverflow.com/questions/61169609
复制相似问题