Last active
October 22, 2021 13:02
-
-
Save ito4303/d80a897aa702593a24245e21cdb1f3ac to your computer and use it in GitHub Desktop.
ggplot2 and color model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
# http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/ | |
# The palette with grey: | |
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", | |
"#F0E442", "#0072B2", "#D55E00", "#CC79A7") | |
data(iris) | |
p <- ggplot(iris) + | |
geom_histogram(aes(Sepal.Length, fill = Species), | |
binwidth = 0.5) + | |
scale_fill_manual(values = cbPalette) | |
ggsave("ggsave.pdf", plot = p, device = "pdf", | |
width = 12, height = 8, units = "cm") | |
pdf("ggplot-grey.pdf", width = 12 / 2.54, height = 8 / 2.54, | |
colormodel = "grey") | |
print(p) | |
dev.off() | |
pdf("ggplot-cmyk.pdf", width = 12 / 2.54, height = 8 / 2.54, | |
colormodel = "cmyk") | |
print(p) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment