Title: | custom theming for ggplot, for personal use |
---|---|
Description: | Collection of (ggplot) theming options for personal use. |
Authors: | Carlos Yanez Santibanez [aut, cre] |
Maintainer: | Carlos Yanez Santibanez <[email protected]> |
License: | CC BY 4.0 |
Version: | 0.0.1.0002 |
Built: | 2025-02-16 04:16:20 UTC |
Source: | https://github.com/carlosyanez/customthemes |
Add logo to plot, option to write into file
add_logo( orig_plot, logo_file, annotation_text, plot_file = "temp.png", plot_dpi = 320, plot_width = NA, plot_height = NA, logo_resize = "60x60", image_extent = "700x60", image_gravity = "west", annotation_colour = "black", google_font = "Roboto", annotation_location = "+61+0", annotation_size = 35, x_pos_round = 0.01, rewrite_file = TRUE )
add_logo( orig_plot, logo_file, annotation_text, plot_file = "temp.png", plot_dpi = 320, plot_width = NA, plot_height = NA, logo_resize = "60x60", image_extent = "700x60", image_gravity = "west", annotation_colour = "black", google_font = "Roboto", annotation_location = "+61+0", annotation_size = 35, x_pos_round = 0.01, rewrite_file = TRUE )
orig_plot |
existing chart |
logo_file |
logo to be added (image file) |
annotation_text |
text to be added next to the text (e.g. twitter handle) |
plot_file |
file where to save the plot |
plot_dpi |
plot file resolution |
plot_width |
plot file width |
plot_height |
plot file height |
logo_resize |
size of the logo when added (magick parameter) |
image_extent |
extent addition (magick parameter) |
image_gravity |
image gravity alignment (magick parameter) |
annotation_colour |
colour of the annotation text |
google_font |
font of the text, from Google fonts |
annotation_location |
relative location of text (from logo, magick parameter) |
annotation_size |
relative size of annotation (from logo, magick parameter) |
x_pos_round |
relative position rounding (magick parameter) |
rewrite_file |
whether to rewrite the file with finished plot |
raster object
Create HTML/Markdown text with Twitter's logo and handle/text
add_social_ref(twitter_handle, logo_size = 9, logo_url = NULL)
add_social_ref(twitter_handle, logo_size = 9, logo_url = NULL)
twitter_handle |
like @abcd |
logo_size |
(default = 9) |
logo_url |
custom image (i.e dark mode). If none provide, will download logo from wikimedia |
text
Custom theme for ggplot maps
custom_map_theme( google_font = "Roboto", map_title_size = 14, legend_pos = "bottom", legend_dir = "horizontal" )
custom_map_theme( google_font = "Roboto", map_title_size = 14, legend_pos = "bottom", legend_dir = "horizontal" )
google_font |
font, from Google Fonts |
map_title_size |
Title's size |
legend_pos |
legend's position (default bottom) |
legend_dir |
legend's direction (defaul horizontal) |
ggplot theme object
Custom theme for ggplot maps, using ggtext for markdown text
custom_map_theme_md( google_font = "Roboto", map_title_size = 14, map_subtitle_size = 12, map_caption_size = 9, legend_pos = "none", legend_dir = "horizontal", title_pos = "plot", background_colour = "white", plot_margin = c(3, 0, 1, 0) )
custom_map_theme_md( google_font = "Roboto", map_title_size = 14, map_subtitle_size = 12, map_caption_size = 9, legend_pos = "none", legend_dir = "horizontal", title_pos = "plot", background_colour = "white", plot_margin = c(3, 0, 1, 0) )
google_font |
font, from Google Fonts |
map_title_size |
Title's size |
map_subtitle_size |
Subtitle's size |
map_caption_size |
Caption's size |
legend_pos |
legend's position (default none) |
legend_dir |
legend's direction (defaul horizontal) |
title_pos |
title's position (default plot) |
background_colour |
background's overall colour (default white) |
plot_margin |
margins c(top,right,bottom,left) - default c(3,0,1,0) |
Custom theme for ggplot plots
custom_plot_theme( google_font = "Roboto", title_colour = "#272928", general_colour = "azure4", background_colour = "#fcf8f7", legend_pos = "right", legend_dir = "vertical" )
custom_plot_theme( google_font = "Roboto", title_colour = "#272928", general_colour = "azure4", background_colour = "#fcf8f7", legend_pos = "right", legend_dir = "vertical" )
google_font |
font, from Google Fonts |
title_colour |
Colour for title and legend textx |
general_colour |
Colour for all other texts in plot |
background_colour |
Background colour |
legend_pos |
legend's position (default right) |
legend_dir |
legend's direction (defaul vertical) |
ggplot theme object
Custom theme for ggplot plots with markdown texts
custom_plot_theme_md( google_font = "Roboto", title_colour = "#272928", general_colour = "azure4", background_colour = "white", legend_pos = "right", legend_dir = "vertical", plot_margin = c(3, 0, 1, 0), title_size = 14, subtitle_size = 12, caption_size = 9, axis_size = 10, legend_size = 8 )
custom_plot_theme_md( google_font = "Roboto", title_colour = "#272928", general_colour = "azure4", background_colour = "white", legend_pos = "right", legend_dir = "vertical", plot_margin = c(3, 0, 1, 0), title_size = 14, subtitle_size = 12, caption_size = 9, axis_size = 10, legend_size = 8 )
google_font |
font, from Google Fonts |
title_colour |
Colour for title and legend textx |
general_colour |
Colour for all other texts in plot |
background_colour |
Background colour |
legend_pos |
legend's position (default right) |
legend_dir |
legend's direction (defaul vertical) |
plot_margin |
margins c(top,right,bottom,left) - default c(3,0,1,0) |
title_size |
Title's size |
subtitle_size |
Subtitle's size |
caption_size |
Caption's size |
axis_size |
text size for axis items |
legend_size |
text size for legend |
ggplot theme object
Custom theme for temperatue strips based on https://dominicroye.github.io/en/2018/how-to-create-warming-stripes-in-r/, modified
custom_strip_theme(google_font = "Roboto", rbrewer_pal = "RdBu")
custom_strip_theme(google_font = "Roboto", rbrewer_pal = "RdBu")
google_font |
font, from Google Fonts |
rbrewer_pal |
RColorBrewer palette used |
ggplot theme object
Small wrapper of formatC for number formatting
digits_formatter(x, sig_digits = 3, nbr_format = "f")
digits_formatter(x, sig_digits = 3, nbr_format = "f")
x |
number to format |
sig_digits |
decimal precission |
nbr_format |
format, default "f" |
formatted number
save ggplot into PNG file
save_image( plot_name, file_name, dpi_value = 600, width_value = NA, height_value = NA, unit_value = NA )
save_image( plot_name, file_name, dpi_value = 600, width_value = NA, height_value = NA, unit_value = NA )
plot_name |
ggplot object |
file_name |
file's name (including .png) |
dpi_value |
resolution (default 600) |
width_value |
width for ggsave |
height_value |
height for ggsave |
unit_value |
unit for ggsave |
saved file in disk
ggplot theme object
Set colour for standard chart fillings and lines
set_plot_colours( line_colour = "darkblue", fill_colour = "deepskyblue", HVline_colour = "orange", alt_fill_colour = "white", alpha_setting = 0.3 )
set_plot_colours( line_colour = "darkblue", fill_colour = "deepskyblue", HVline_colour = "orange", alt_fill_colour = "white", alpha_setting = 0.3 )
line_colour |
general colour for lines |
fill_colour |
fill colour for plots like density plots |
HVline_colour |
colour of vertical and horizontal lines |
alt_fill_colour |
fill colour for plots like boxplots |
alpha_setting |
alpha value when fill_colour is used |
no output