Created
February 11, 2021 11:21
-
-
Save tanerumit/e1d18ec91b8db2c1923737ac652c00b2 to your computer and use it in GitHub Desktop.
Essential #ggplot2 theme settings
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
| https://www.datanovia.com/en/blog/ggplot-legend-title-position-and-labels/ | |
| theme( | |
| # Legend title and text labels | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| # Title font color size and face | |
| legend.title = element_text(color, size, face), | |
| # Title alignment. Number from 0 (left) to 1 (right) | |
| legend.title.align = NULL, | |
| # Text label font color size and face | |
| legend.text = element_text(color, size, face), | |
| # Text label alignment. Number from 0 (left) to 1 (right) | |
| legend.text.align = NULL, | |
| # Legend position, margin and background | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| # Legend position: right, left, bottom, top, none | |
| legend.position = "right", | |
| # Margin around each legend | |
| legend.margin = margin(0.2, 0.2, 0.2, 0.2, "cm"), | |
| # Legend background | |
| legend.background = element_rect(fill, color, size, linetype), | |
| # Legend direction and justification | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| # Layout of items in legends ("horizontal" or "vertical") | |
| legend.direction = NULL, | |
| # Positioning legend inside or outside plot | |
| # ("center" or two-element numeric vector) | |
| legend.justification = "center", | |
| # Background underneath legend keys | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| legend.key = element_rect(fill, color), # Key background | |
| legend.key.size = unit(1.2, "lines"), # key size (unit) | |
| legend.key.height = NULL, # key height (unit) | |
| legend.key.width = NULL, # key width (unit) | |
| # Spacing between legends. | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| legend.spacing = unit(0.4, "cm"), | |
| legend.spacing.x = NULL, # Horizontal spacing | |
| legend.spacing.y = NULL, # Vertical spacing | |
| # Legend box | |
| #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| # Arrangement of multiple legends ("horizontal" or "vertical") | |
| legend.box = NULL, | |
| # Margins around the full legend area | |
| legend.box.margin = margin(0, 0, 0, 0, "cm"), | |
| # Background of legend area: element_rect() | |
| legend.box.background = element_blank(), | |
| # The spacing between the plotting area and the legend box | |
| legend.box.spacing = unit(0.4, "cm") | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment