R
package dedicated to data visualization. It
can greatly improve the quality and aesthetics of
your graphics, and will make you much more efficient in
creating them.ggplot2
tips, check
the
dedicated page
of the gallery!
fill
and color
ggplot2
allows to customize the shape colors thanks to
its fill
and color
arguments. It is
important to understand the diffence between both.
The fill
property changes the color inside the shape,
while the color
property modifies its border color.
Note that color
and colour
always have the
same effect.
library(ggplot2) ggplot(mtcars, aes(x=drat)) + geom_density( color="purple", fill="#69b3a2", size=2 )
ggplot2
ggplot2
allows to automatically assign a marker color
to a variable. Basically, you just have to specify the variable in
the aes()
part of the call.
Moreover, a legend will come for free! 🎉
library(ggplot2) ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=6)
ggplot2
ggplot2
provides a color scale by default. Several
methods are available to change it:
→ Included in ggplot2
→ R Color Brewer
→ Viridis
→ All other: Paletteer
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
ggplot2
natively supports several methods to
customize the color palette:
All the existing color palettes are available in
Paletteer
. Just specify the package and palette
names to use!
All the existing color palettes are available in
Paletteer
. Just specify the package and palette
names to use!
All the existing color palettes are available in
Paletteer
. Just specify the package and palette
names to use!
All the existing color palettes are available in
Paletteer
. Just specify the package and palette
names to use!
All the existing color palettes are available in
Paletteer
. Just specify the package and palette
names to use!
p <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=6)
p + scale_color_hue(h = c(180, 300))
p + scale_color_manual(values=c("#69b3a2", "purple", "black"))
p + scale_color_grey()
p + scale_color_brewer(palette = "BuPu")
p + scale_color_brewer(palette = "RdYlBu")
p + scale_color_brewer(palette = "Paired")
p + scale_color_brewer(palette = "PuOr")
p + scale_color_brewer(palette = "Spectral")
p + scale_color_brewer(palette = "Pastel1")
p + scale_color_viridis(discrete=TRUE, option="magma")
p + scale_color_viridis(discrete=TRUE, option="inferno")
p + scale_color_viridis(discrete=TRUE, option="plasma")
p + scale_color_viridis(discrete=TRUE, option="viridis")
p + scale_color_viridis(discrete=TRUE, option="cividis")
p + scale_color_paletteer_d(nord, aurora)
p + scale_color_paletteer_d(awtools, a_palette)
p + scale_color_paletteer_d(dutchmasters, milkmaid)
scale_color_paletteer_d(ggsci, nrc_npg)
p + scale_color_paletteer_d(ggthemes, calc)
p + scale_color_hue(h = c(180, 300))See all See all See all See all See all See all See all See all See all See all See all
Paletteer
: The Definitive Catalog of R Color Palettes
Paletteer is an R package that provides over 2500+ ready-to-use color palettes for your charts.
Using paletteer
is simple. It comes with a few functions
like scale_fill_paletteer_d
which allows to utilize any
of the 2500+ palettes in your plot. I've written a comprehensive
introduction to Paletteer here.
Additionally, I've developed a lightweight application that allows you to explore these 2500+ palettes quickly. It includes a variety of features that I'm sure you'll enjoy.
Color Palette FinderI few stuff I often need to remember:
library(paletteer) ; paletteer_c("viridis::inferno", n=10)