How to make ggplot2 graphics compatible with black

2019-05-07 08:48发布

问题:

Is there a way to convert ggplot2 plots into black-and-white versions without rewriting much of their code, so that the black-and-white versions remain readable?

For instance, to replace scale_fill_gradient with scale_fill_grey? Or automatically make photocopy-friendly transformations as sites like http://colorbrewer2.org/ advise. (Unfortunately, textures are not an option, as ggplot2 doesn't support them.)

It's clearly possible with if ... else and custom functions, but is there a more general solution?

回答1:

My second line in every ggplot figure I make is

theme_bw()

so

qplot(mpg, wt, data = mtcars) +
  theme_bw()