Cambiar fuente a mapas

46 views
Skip to first unread message

Alejandro Muñoz Fernández

unread,
Nov 9, 2022, 12:58:16 PM11/9/22
to mxmaps
Hola Diego,

Me gustaría saber cómo cambiar el tipo y tamaño de letra a la leyenda de los mapas, no sé si pueda ser compatible con la opción "family" de ggplot:

library(extrafont)
loadfonts(device="win")
wf <- windowsFonts()
names(wf[wf=="TT Times New Roman"])

ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
  ggtitle("Fuel Efficiency of 32 Cars")  +
  theme(text=element_text(size=16,  family="serif"))

¡Muchas gracias!

Diego Valle-Jones

unread,
Nov 9, 2022, 1:22:21 PM11/9/22
to mxmaps
Hola Alejandro,

Creo lo puedes hacer cambiando el parámetro de la función theme() a legend.text como en el siguiente código

library("mxmaps")
library("extrafont")
library("ggplot2")

font_import()
loadfonts(device = "win")

df_mxstate_2020$value <- df_mxstate_2020$pop
mxstate_choropleth(df_mxstate_2020,
                   title = "Total population, by state") +
  theme(legend.text = element_text(color="red",
                                   size=20,
                                   face="bold",
                                   family="Times New roman"))
Reply all
Reply to author
Forward
0 new messages