Last active
February 1, 2023 21:23
-
-
Save mattgalbraith/f082ed7d152729f4ae72383e564a70e8 to your computer and use it in GitHub Desktop.
Default theme for ggplot
This file contains 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
## Setting and modifying default theme for plots | |
theme_set(theme_gray(base_size=12, base_family="Arial") + | |
theme( | |
panel.border=element_rect(colour="black", fill="transparent"), | |
plot.title=element_text(face="bold", hjust=0), | |
axis.text=element_text(color="black", size=14), | |
axis.text.x=element_text(angle=0, hjust=0.5), | |
axis.ticks = element_line(color = "black"), # make sure tick marks are black | |
panel.background=element_blank(), | |
panel.grid=element_blank(), | |
plot.background=element_blank(), | |
strip.background = element_blank(), # facet label borders | |
legend.key=element_blank(), # remove grey bg from legend elements | |
legend.background=element_blank() | |
) | |
) | |
# to source this in R, run: | |
# devtools::source_gist("https://gist.github.com/mattgalbraith/f082ed7d152729f4ae72383e564a70e8", filename = "ggplot_theme.R") | |
# May need to add/update Github token | |
# For details see https://gist.github.com/mattgalbraith/0f9f2d75023be5355b693cb832b9abef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment