Below plots will be used as examples, to provide customization features.
library(ggplot2)
p_colour <-
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
geom_point(size = 4)
p_fill <-
ggplot(diamonds, aes(x = clarity, fill = color)) +
geom_bar(position = position_dodge())
df <- data.frame(
x = runif(100),
y = runif(100),
z1 = rnorm(100),
z2 = abs(rnorm(100))
)
p_gradient <-
ggplot(df, aes(x, y)) +
geom_point(aes(colour = z1), size = 3) +
theme_bw()
p_fill_gradient <-
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density))Installation
The moment you load a g6tr package, the fonts we use are
copied to your directory.
Please go to the g6tr/fonts directory, open up the
following fonts and press install:
Open Sans-Italic.ttfOpen Sans-Regular.ttfOpen Sans-Light.ttfAnekLatin-Medium.ttfAnekLatin-Regular.ttfAnekLatin-SemiBold.ttf
Be aware that if you want to manually specify the family above elsewhere, you need to use this:
grDevices::windowsFonts(
`Open Sans Light` = grDevices::windowsFont("Open Sans Light")
)
grDevices::windowsFonts(
`Anek Latin Medium"` = grDevices::windowsFont("Anek Latin Medium"")
)Your font names are then:
- Open Sans Light
- Anek Latin Medium
In the case you would like to manually replace fonts in the plot, you
could do it like
geom_text(font_family = "IBM Plex Sans Medium").
g6tr_pal() - palettes
You can use Gradient branded palettes provided in
g6tr:
with the usage of g6tr_pal() function
# g6tr_pal('core') is a function, g6tr_pal('core')(7) is a call to export 7 first colors
scales::show_col(g6tr_pal('core')(8))


# g6tr_pal('names') let's you see the values and the initial order of the color palette
g6tr_pal('names') core_blue core_green core_red core_yellow core_orange
"#36c8ef" "#50bd90" "#de425b" "#ffcf60" "#EF8150"
core_darkblue core_purple core_magenta black grey_1
"#3693EF" "#826CC4" "#A2469E" "#000000" "#5b5b5b"
grey_2 grey_3 grey_4 grey_5 white
"#858585" "#cccccc" "#dddddd" "#eeeeee" "#FFFFFF"
# g6tr_pal('core') is a function, g6tr_pal('core')(4) is a call to return 4 first colors
# rearrange the order of colors returned
g6tr_pal('core', order = c(3, 2, 1, 7:4))(4)[1] "#de425b" "#50bd90" "#36c8ef" "#826CC4"
those values can be used in manual settings of
scales.
p_colour + scale_color_manual(values = g6tr_pal('core')(3))
p_colour + scale_color_manual(values = g6tr_pal('core', order = c(3, 2, 1, 4:7))(3))
p_fill + scale_fill_manual( values = g6tr_pal()(7)) # core by default
theme_g6tr() - fonts and layout
This theme automatically loads all fonts if you have installed them.
The basic text geom_ are also changed to use our fonts.
Take a regular text geom for example:
ggplot(mtcars,
aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) +
geom_point() +
geom_label() +
theme_g6tr()
However, if for example, you use the ggrepel
package and apply the geom_repel, you’ll need to use the
following:
library(ggrepel)
update_geom_defaults("text_repel",
list(colour = "#525252",
family = "Open Sans Light",
size = 3))
#OR
ggplot(mtcars,
aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) +
geom_point() +
geom_label_repel(family = "Open Sans Light", size = 3) +
theme_g6tr()
White Theme
The default uses major gridlines on the X-axis. This goes well
together with the coord_flip() function. However. If you
decide to remove the coord_flip(), make sure you set
x_grid = FALSE in theme_g6tr().
ggplot(diamonds, aes(x = clarity, fill = color)) +
geom_bar(position = position_dodge()) +
theme_g6tr() +
labs(title = 'Title in Anek Latin Medium',
subtitle = 'Subtitle in Anek Latin Medium',
x = 'Open Sans Light',
y = 'Open Sans Light') +
coord_flip() 
ggplot(diamonds, aes(x = clarity, fill = color)) +
geom_bar(position = position_dodge()) +
theme_g6tr(x_grid = FALSE) +
labs(title = 'Title in Anek Latin Medium',
subtitle = 'Subtitle in Anek Latin Medium',
x = 'Open Sans Light',
y = 'Open Sans Light') +
scale_y_continuous(expand = c(0,0))
Finalizing & saving your plot
You can find the created plots in the directory of the package:
g6tr/inst/plots
Transparent Background
myplot <-
ggplot(diamonds, aes(x = clarity, fill = color)) +
geom_bar(position = position_dodge()) +
theme_g6tr(transparent = TRUE, base_size = 16) +
labs(title = 'Title in Anek Latin Medium',
subtitle = 'Subtitle in Anek Latin Medium',
x = 'Open Sans Light',
y = 'Open Sans Light') +
coord_flip()Simple blank transparent themed plot.
# Invisibly returns a plot as well so you can still use it
finalise_plot(
plot = myplot,
filepath = '',
width_pixels = 600,
height_pixels = 800,
)
White Background
myplot <-
ggplot(diamonds, aes(x = clarity, fill = color)) +
geom_bar(position = position_dodge()) +
theme_g6tr(base_size = 16) +
labs(title = 'Title in Anek Latin Medium',
subtitle = 'Subtitle in Anek Latin Medium',
x = 'Open Sans Light',
y = 'Open Sans Light') +
coord_flip()Adding a footer with both a source on the left and a logo on the right.
# Invisibly returns a plot as well so you can still use it
finalise_plot(
plot = myplot,
add_footer = T,
filepath = '',
source = 'Source: Left hand side',
width_pixels = 600,
height_pixels = 800,
logo = T, #Whether to include the g6tr logo or not
brand = 'g6tr',
background_color = 'white'
)
Saving the plot without a footer
# Invisibly returns a plot as well so you can still use it
finalise_plot(
plot = myplot,
add_footer = F,
filepath = '',
width_pixels = 600,
height_pixels = 800,
logo = F, #Should be False if no footer (also done automatically)
)