简体   繁体   中英

Adjusting font and other graphical parameters in Choroplethr

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM