【发布时间】:2018-11-05 07:52:58
【问题描述】:
我用 ggplot 制作了一个非常漂亮的小情节,它看起来很棒。我有一些横杆,然后是一些横杆。我正在使用ggthemes 包中的theme_economist(),我想将条形设为该主题中的一种颜色,并将横条设为对比色。但我不知道如何进入主题并为这些元素挑选几种颜色。我可以将它们更改为指定的颜色,也可以将它们更改为特定的十六进制颜色,但似乎我应该能够进入主题并说,“给我这个主题的两种对比色!”我该怎么做?
这是一个展示我所拥有的reprex...
library(tidyverse)
library(ggthemes)
prices <- data.frame(year=2001:2010,
price=rnorm(10))
additional_junk <- data.frame(year=2001:2010,
thing=rnorm(10))
g_price <- ggplot() + theme_economist() +
scale_fill_economist() +
scale_colour_economist() +
geom_bar(aes(y = price , x = year),
data = prices, stat="identity") +
geom_crossbar(data=additional_junk, aes(x=year, y=thing,
ymin=0, ymax=0)
)
g_price
【问题讨论】:
-
这里是GitHub上的代码:github.com/jrnold/ggthemes/blob/master/R/economist.R