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
require(extrafont) | |
require(ggplot2) | |
font_import(pattern = "GIL", prompt = FALSE) # Import Gill family | |
loadfonts(device="win") # Load them all | |
fonts() # See what fonts are available | |
zp1 <- ggplot(data = iris, | |
aes(x = Sepal.Length, y = Sepal.Width, label = Species)) | |
zp1 <- zp1 + geom_text(family = "Gill Sans MT") | |
zp1 <- zp1 + theme(text=element_text(family="Gill Sans Ultra Bold")) |
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
### Sourcing | |
sourceDir <- function(path, trace = TRUE, ...) { | |
for (nm in list.files(path, pattern = "\\.[RrSsQq]$")) { | |
if(trace) cat(nm,":") | |
source(file.path(path, nm), ...) | |
if(trace) cat("\n") | |
} | |
} |
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
lmp <- function (modelobject) { | |
if (class(modelobject) != "lm") stop("Not an object of class 'lm' ") | |
f <- summary(modelobject)$fstatistic | |
p <- pf(f[1],f[2],f[3],lower.tail=F) | |
attributes(p) <- NULL | |
return(p) | |
} |
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
library(tidyverse) | |
library(gganimate) | |
## standard ggplot2 | |
myPlot <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) + | |
geom_point(alpha = 0.7, show.legend = FALSE) + | |
scale_colour_manual(values = country_colors) + | |
scale_size(range = c(2, 12)) + | |
scale_x_log10() + | |
# Here comes the gganimate specific bits |
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
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 |