Adjusting font and other graphical parameters in Choroplethr

208 views Asked by At

I am using the Choroplethr package to generate some maps for a forthcoming publication. Does anyone know how to adjust the graphical parameters of the outputted graphics? (Specifically, I am hoping to change the font to the journal-required font.)

library(choroplethr)
library(choroplethrMaps)
library(ggplot2)

data(county.regions)
texas.counties<-county.regions[county.regions$state.name=="texas",]

fakedata<-as.data.frame(texas.counties$region)
fakedata$value<-runif(n=254, min=0, max=1)
colnames(fakedata)[1]<-"region"

county_choropleth(fakedata,
                  state_zoom = c("texas"),
                  num_colors=1,
                  legend = "test") 

Example Output

So in this particular example, I'm hoping to change the font displayed in the legend ("test", "0.25," "0.50," "0.75").

Many thanks!

1

There are 1 answers

1
Lawrence On

Adding and editing the theme() argument from ggplot2 worked. Although I imagine there are alternative ways to set the font, I am pasting the code I used and corresponding output below in case helpful to others.

library(choroplethr)
library(choroplethrMaps)
library(ggplot2)

data(county.regions)
texas.counties<-county.regions[county.regions$state.name=="texas",]

fakedata<-as.data.frame(texas.counties$region)
fakedata$value<-runif(n=254, min=0, max=1)
colnames(fakedata)[1]<-"region"

county_choropleth(fakedata,
                  state_zoom = c("texas"),
                  num_colors=1,
                  legend = "test") + theme(text = element_text(family = "Times New Roman")) 

Updated Example Output