无法使用update_geom_defaults更新geom_histogram默认值

时间:2019-07-02 14:42:18

标签: r ggplot2

我想更改geoms中所有ggplot2的默认颜色和填充。我遇到了this postthis post,这有助于我开始更改默认值。

但是,当我尝试使用update_geom_defaultsupdate_stat_defaults更改直方图的默认值时,出现错误:

  

错误:找不到名为“直方图”的geom

是否可以使用geom_histogramupdate_*_defaults更新颜色和填充?

代码:

library(tidyverse)
update_geom_defaults("histogram", list(fill = "black", colour = "black"))

update_stat_defaults("histogram", list(fill = "black", colour = "black"))
#works in ggplot call
ggplot(mtcars)+
    geom_histogram(aes(x=mpg), bins = 5, fill = "black")
#works for other geom_*
update_geom_defaults("point", list(fill = "green", colour = "green"))

ggplot(mtcars)+
  geom_point(aes(x=mpg,y=cyl))

#additional arguments that do not work with either update function
neither <- c("freqpoly", "histogram",   "jitter","sf_label","sf_text")

ggplot2使用版本R 3.6和3.2.0

0 个答案:

没有答案