Feature request: (sub)theme
argument for guide_legend()
and friends
#5348
Labels
(sub)theme
argument for guide_legend()
and friends
#5348
Of the 21 arguments that
guide_legend()
has, more than half (11) are proxies for theme settings.title.theme
proxiestheme(legend.title)
title.hjust
proxiestheme(legend.title = element_text(hjust))
title.hjust
proxiestheme(legend.title = element_text(vjust))
label
proxiestheme(legend.text = element_text/blank())
label.theme
proxiestheme(legend.text = element_text())
label.hjust
proxiestheme(legend.text = element_text(hjust))
label.vjust
proxiestheme(legend.text = element_text(vjust))
keywidth
/barwidth
proxiestheme(legend.key.width)
keyheight
/barheight
proxiestheme(legend.key.height)
direction
proxiestheme(legend.direction)
.default.unit
is just syntactic sugar for thekeywidth
andkeyheight
arguments.These are great for customising one legend in particular. However, it is a bit of a burden on the code to have this messy, manual layer of inheritance underneath the regular theme's inheritance. In addition, there are also theme settings that apply to all legends at once and cannot be customised per legend, even though you might want to.
You can set the following in
theme()
but not at the legend level:legend.background
legend.margin
legend.spacing(.{x/y})
legend.key
As an aside, there is also the inverse case where styling options are provided in the
guide_*()
function but not in the theme:guide_colourbar(frame, frame.colour, frame.linewidth, frame.linetype, ticks, ticks.colour, ticks.linewidth, ticks.length)
guide_coloursteps()
guide_bins(axis.colour, axis.linewidth, axis.arrow, ticks, ticks.length)
Adding these "missing" theme settings to guides makes their formals even more complicated than they already are.
So I'm proposing an alternative: get rid of all (or most of) these theme arguments in legends, and instead add one
subtheme
(or justtheme
) argument to guides that takes a (incomplete) theme object. This then:guide_*()
functions.actual_theme <- plot_theme + subtheme
once instead of meticulously curating inheritance.Moreover, it would synergise well with the syntactic sugar of #5301, where we then could specify
subtheme = theme_legend(...)
and be spared the hassle to write out all the theme arguments in full.The text was updated successfully, but these errors were encountered: