F Styling Plots
F.1 Aesthetics
F.1.1 Colour/Fill
The colour
argument changes the point and line colour, while the fill
argument changes the interior colour of shapes. Type colours()
into the console to see a list of all the named colours in R. Alternatively, you can use hexadecimal colours like "#FF8000"
or the rgb()
function to set red, green, and blue values on a scale from 0 to 1.
Hover over a colour to see its R name.
- black
- gray1
- gray2
- gray3
- gray4
- gray5
- gray6
- gray7
- gray8
- gray9
- gray10
- gray11
- gray12
- gray13
- gray14
- gray15
- gray16
- gray17
- gray18
- gray19
- gray20
- gray21
- gray22
- gray23
- gray24
- gray25
- gray26
- gray27
- gray28
- gray29
- gray30
- gray31
- gray32
- gray33
- gray34
- gray35
- gray36
- gray37
- gray38
- gray39
- gray40
- dimgray
- gray42
- gray43
- gray44
- gray45
- gray46
- gray47
- gray48
- gray49
- gray50
- gray51
- gray52
- gray53
- gray54
- gray55
- gray56
- gray57
- gray58
- gray59
- gray60
- gray61
- gray62
- gray63
- gray64
- gray65
- darkgray
- gray66
- gray67
- gray68
- gray69
- gray70
- gray71
- gray72
- gray73
- gray74
- gray
- gray75
- gray76
- gray77
- gray78
- gray79
- gray80
- gray81
- gray82
- gray83
- lightgray
- gray84
- gray85
- gainsboro
- gray86
- gray87
- gray88
- gray89
- gray90
- gray91
- gray92
- gray93
- gray94
- gray95
- gray96
- gray97
- gray98
- gray99
- white
- snow4
- snow3
- snow2
- snow
- rosybrown4
- rosybrown
- rosybrown3
- rosybrown2
- rosybrown1
- lightcoral
- indianred
- indianred4
- indianred2
- indianred1
- indianred3
- brown4
- brown
- brown3
- brown2
- brown1
- firebrick4
- firebrick
- firebrick3
- firebrick1
- firebrick2
- darkred
- red3
- red2
- red
- mistyrose3
- mistyrose4
- mistyrose2
- mistyrose
- salmon
- tomato3
- coral4
- coral3
- coral2
- coral1
- tomato2
- tomato
- tomato4
- darksalmon
- salmon4
- salmon3
- salmon2
- salmon1
- coral
- orangered4
- orangered3
- orangered2
- lightsalmon3
- lightsalmon2
- lightsalmon
- lightsalmon4
- sienna
- sienna3
- sienna2
- sienna1
- sienna4
- orangered
- seashell4
- seashell3
- seashell2
- seashell
- chocolate4
- chocolate3
- chocolate
- chocolate2
- chocolate1
- linen
- peachpuff4
- peachpuff3
- peachpuff2
- peachpuff
- sandybrown
- tan4
- peru
- tan2
- tan1
- darkorange4
- darkorange3
- darkorange2
- darkorange1
- antiquewhite3
- antiquewhite2
- antiquewhite1
- bisque4
- bisque3
- bisque2
- bisque
- burlywood4
- burlywood3
- burlywood
- burlywood2
- burlywood1
- darkorange
- antiquewhite4
- antiquewhite
- papayawhip
- blanchedalmond
- navajowhite4
- navajowhite3
- navajowhite2
- navajowhite
- tan
- floralwhite
- oldlace
- wheat4
- wheat3
- wheat2
- wheat
- wheat1
- moccasin
- orange4
- orange3
- orange2
- orange
- goldenrod
- goldenrod1
- goldenrod4
- goldenrod3
- goldenrod2
- darkgoldenrod4
- darkgoldenrod
- darkgoldenrod3
- darkgoldenrod2
- darkgoldenrod1
- cornsilk
- cornsilk4
- cornsilk3
- cornsilk2
- lightgoldenrod4
- lightgoldenrod3
- lightgoldenrod
- lightgoldenrod2
- lightgoldenrod1
- gold4
- gold3
- gold2
- gold
- lemonchiffon4
- lemonchiffon3
- lemonchiffon2
- lemonchiffon
- palegoldenrod
- khaki
- darkkhaki
- khaki4
- khaki3
- khaki2
- khaki1
- ivory4
- ivory3
- ivory2
- ivory
- beige
- lightyellow4
- lightyellow3
- lightyellow2
- lightyellow
- lightgoldenrodyellow
- yellow4
- yellow3
- yellow2
- yellow
- olivedrab
- olivedrab4
- olivedrab3
- olivedrab2
- olivedrab1
- darkolivegreen
- darkolivegreen4
- darkolivegreen3
- darkolivegreen2
- darkolivegreen1
- greenyellow
- chartreuse4
- chartreuse3
- chartreuse2
- lawngreen
- chartreuse
- honeydew4
- honeydew3
- honeydew2
- honeydew
- darkseagreen4
- darkseagreen
- darkseagreen3
- darkseagreen2
- darkseagreen1
- lightgreen
- palegreen
- palegreen4
- palegreen3
- palegreen1
- forestgreen
- limegreen
- darkgreen
- green4
- green3
- green2
- green
- mediumseagreen
- seagreen
- seagreen3
- seagreen2
- seagreen1
- mintcream
- springgreen4
- springgreen3
- springgreen2
- springgreen
- aquamarine3
- aquamarine2
- aquamarine
- mediumspringgreen
- aquamarine4
- turquoise
- mediumturquoise
- lightseagreen
- azure4
- azure3
- azure2
- azure
- lightcyan4
- lightcyan3
- lightcyan2
- lightcyan
- paleturquoise
- paleturquoise4
- paleturquoise3
- paleturquoise2
- paleturquoise1
- darkslategray
- darkslategray4
- darkslategray3
- darkslategray2
- darkslategray1
- cyan4
- cyan3
- darkturquoise
- cyan2
- cyan
- cadetblue4
- cadetblue
- turquoise4
- turquoise3
- turquoise2
- turquoise1
- powderblue
- cadetblue3
- cadetblue2
- cadetblue1
- lightblue4
- lightblue3
- lightblue
- lightblue2
- lightblue1
- deepskyblue4
- deepskyblue3
- deepskyblue2
- deepskyblue
- skyblue
- lightskyblue4
- lightskyblue3
- lightskyblue2
- lightskyblue1
- lightskyblue
- skyblue4
- skyblue3
- skyblue2
- skyblue1
- aliceblue
- slategray
- lightslategray
- slategray3
- slategray2
- slategray1
- steelblue4
- steelblue
- steelblue3
- steelblue2
- steelblue1
- dodgerblue4
- dodgerblue3
- dodgerblue2
- dodgerblue
- lightsteelblue4
- lightsteelblue3
- lightsteelblue
- lightsteelblue2
- lightsteelblue1
- slategray4
- cornflowerblue
- royalblue
- royalblue4
- royalblue3
- royalblue2
- royalblue1
- ghostwhite
- lavender
- midnightblue
- navy
- blue4
- blue3
- blue2
- blue
- darkslateblue
- slateblue
- mediumslateblue
- lightslateblue
- slateblue1
- slateblue4
- slateblue3
- slateblue2
- mediumpurple4
- mediumpurple3
- mediumpurple
- mediumpurple2
- mediumpurple1
- purple4
- purple3
- blueviolet
- purple1
- purple2
- purple
- darkorchid
- darkorchid4
- darkorchid3
- darkorchid2
- darkorchid1
- darkviolet
- mediumorchid4
- mediumorchid3
- mediumorchid
- mediumorchid2
- mediumorchid1
- thistle4
- thistle3
- thistle
- thistle2
- thistle1
- plum4
- plum3
- plum2
- plum1
- plum
- violet
- darkmagenta
- magenta3
- magenta2
- magenta
- orchid4
- orchid3
- orchid
- orchid2
- orchid1
- maroon4
- violetred
- maroon3
- maroon2
- maroon1
- mediumvioletred
- deeppink3
- deeppink2
- deeppink
- deeppink4
- hotpink2
- hotpink1
- hotpink4
- hotpink
- violetred4
- violetred3
- violetred2
- violetred1
- hotpink3
- lavenderblush4
- lavenderblush3
- lavenderblush2
- lavenderblush
- maroon
- palevioletred4
- palevioletred3
- palevioletred
- palevioletred2
- palevioletred1
- pink4
- pink3
- pink2
- pink1
- pink
- lightpink
- lightpink4
- lightpink3
- lightpink2
- lightpink1
F.2 Palettes
Discrete palettes change depending on the number of categories.
F.2.1 Viridis Palettes
Viridis palettes are very good for colourblind-safe and greyscale-safe plots. The work with any number of categories, but are best for larger numbers of categories or continuous colours.
F.2.1.1 Discrete Viridis Palettes
Set discrete viridis colours with scale_colour_viridis_d()
or scale_fill_viridis_d()
and set the option
argument to one of the options below. Set direction = -1
to reverse the order of colours.
If the end colour is too light for your plot or the start colour too dark, you can set the begin
and end
arguments to values between 0 and 1, such as scale_colour_viridis_c(begin = 0.1, end = 0.9)
.
F.2.1.2 Continuous Viridis Palettes
Set continuous viridis colours with scale_colour_viridis_c()
or scale_fill_viridis_c()
and set the option
argument to one of the options below. Set direction = -1
to reverse the order of colours.
F.2.2 Brewer Palettes
Brewer palettes give you a lot of control over plot colour and fill. You set them with scale_color_brewer()
or scale_fill_brewer()
and set the palette
argument to one of the palettes below. Set direction = -1
to reverse the order of colours.
F.2.2.1 Qualitative Brewer Palettes
These palettes are good for categorical data with up to 8 categories (some palettes can handle up to 12). The "Paired" palette is useful if your categories are arranged in pairs.
F.2.2.2 Sequential Brewer Palettes
These palettes are good for up to 9 ordinal categories with a lot of categories.
F.2.2.3 Diverging Brewer Palettes
These palettes are good for ordinal categories with up to 11 levels where the centre level is a neutral or baseline category and the levels above and below it differ in an important way, such as agree versus disagree options.
F.3 Themes
ggplot2
has 8 built-in themes that you can add to a plot like plot + theme_bw()
or set as the default theme at the top of your script like theme_set(theme_bw())
.
F.3.1 ggthemes
You can get more themes from add-on packages, like ggthemes
. Most of the themes also have custom scale_
functions like scale_colour_economist()
. Their website has extensive examples and instructions for alternate or dark version sof these themes.