GeezerVison is showing github.com — Multiple line titles and subtitles · Issue #97 · riatelab/mapsf
Multiple line titles and subtitles #97DescriptionIs it possible to add a "subtitle" argument to the mf_layout() function so the subtitle text would get under the title without moving it up, out of the plot box, and with an other font.
For now i use the "\n" escape character but it's behaviour is tricky and I need to adjust differents sizes in the themes options
library(mapsf)
# Import the sample dataset
mtq <- mf_get_mtq()
# change theme
mf_theme(x="sol_dark")
# Plot the base map
mf_map(x = mtq)
# Plot proportional symbols
mf_map(x = mtq, var = "POP", type = "prop", leg_pos = "topright")
# Plot a map layout
mf_layout(
title = "Population in Martinique\nCeci est un sous-titre
",
credits = "T. Giraud; Sources: INSEE & IGN, 2018"
)
With margins and title line tweeking
library(mapsf)
# Import the sample dataset
mtq <- mf_get_mtq()
# change theme
mf_theme(x="sol_dark", title_line = 4, mar = c(1, 1, 4, 1))
# Plot the base map
mf_map(x = mtq)
# Plot proportional symbols
mf_map(x = mtq, var = "POP", type = "prop", leg_pos = "topright")
# Plot a map layout
mf_layout(
title = "Population in Martinique\nCeci est un sous-titre",
credits = "T. Giraud; Sources: INSEE & IGN, 2018"
)
Thank you ! ActivityrCarto commented on Sep 1, 2026 That's a good idea. I'll do something about it soon. Meanwhile you can also use mf_text() (inside the plot box, though).
library(mapsf)
m <- mf_get_mtq()
mf_map(m)
mf_title("Main title, in the title zone", pos = "left")
mf_text(x = "topleft", txt = "Sub-title, in the map zone",
cex = 1, font = 2, adj = c(0, 1))
mf_arrow(pos = "topleft", adj = c(0, -4))
mf_frame(extent = "map")

Or you can use 2 mf_tite() calls (inside the title area, but not easy to use various title sizes + theme tweaks):
library(mapsf)
mf_theme(x="sol_dark", title_line = 3.5, mar = c(.5, .5, 4, .5))
m <- mf_get_mtq()
mf_map(m)
mf_title("First Title\n", font = 2, banner = F)
mf_title("\nSecond Title", font = 3, bg = NA, fg = "red")

rCarto commented on Nov 9, 2026 In current dev version it is possible to display a title and a subtitle with a combination of mf_theme() parameters and mf_text() calls with xpd = TRUE.
library(mapsf)
mtq <- mf_get_mtq()
mf_theme("sol_dark", mar = c(0, 0, 3, 0), title_line = 3)
mf_map(mtq)
mf_text(x = "topleft", txt = "Main Title", adj = c(0, 11), cex = 1.5, font = 2, xpd = TRUE)
mf_text(x = "topleft", txt = "Sub Title", adj = c(0, 5), cex = 1, xpd = TRUE)

Created on 2026-11-09 with reprex v2.1.1
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|