Skip to content

Instantly share code, notes, and snippets.

View DrK-Lo's full-sized avatar

Katie Lotterhos DrK-Lo

View GitHub Profile
@DrK-Lo
DrK-Lo / ggplot_theme_lotterhos
Created December 9, 2022 20:04
GGplot theme Lotterhos
ggtheme <- theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), panel.border=element_blank(), axis.line = element_line(colour="grey30"), axis.title = element_text(colour="grey20"), axis.text = (element_text(colour="grey30")), legend.title = element_text(colour="grey20"), legend.text = element_text(colour="grey30"))
to use it, just use:
ggplot(data) + geom_point(aes(x=x, y=y)) + ggtheme
par(xpd=NA, oma=c(4,0,0,0), mar=c(2,4,0,0),mfrow=c(1,1))
plot(1,1, xlim=c(-1,1), ylim=c(0,1))
# This is for a plot with x-axis from -1 to 1 and y axis from 0 to 1. It plots a legend in the bottom margin
legend(-1,-0.25, legend=c("high sal.", "low sal."), bty="n", adj=0, fill=c("grey", NA), horiz=TRUE)
@DrK-Lo
DrK-Lo / Install_ifNeeded.R
Last active June 9, 2021 07:46
Easy code for installing packages in R (if not installed) and calling their libraries
packages_needed <- c("raster", "FNN", "RColorBrewer", "colorRamps", "adehabitatLT",
"data.table", "tidyverse", "fields", "ggplot2", "hexbin",
"rgdal", "tmap", "gstat", "sp", "maptools", "sf", "fasterize",
"fansi", "raster", "tmap", "gstat", "ContourFunctions","ash"
)
for (i in 1:length(packages_needed)){
if(!(packages_needed[i] %in% installed.packages())){install.packages(packages_needed[i])}
}