← Back to all sparks
M

maplegend

ANALYTICS
Velocity0.0

Create legends for maps and other graphics. Contribute to riatelab/maplegend development by creating an account on GitHub.

The legend engine mapsf spun out, now covering legend types the parent map package can draw.

cartographylegendsbase-graphicsspatialr-package
Current state
maplegend draws the legends for base-R thematic maps, extracted from mapsf so both packages could evolve the legend vocabulary independently. It has been catching up to the map types it has to serve: 0.6.0 added choro_point, choro_line, and choro_symb for choropleth legends rendered on circles, lines, and symbols, following the histogram legend type in 0.4.0. Considerable effort has gone into behaving correctly when the plot aspect ratio is not 1, which required refactoring most of the package in 0.4.0 and still produced a proportional-symbol segment sizing fix in 0.6.3.
Where it's heading
This is a support library whose backlog is defined by its caller. Every legend type mapsf can produce needs a matching legend renderer, and the release notes are dominated by spacing, offset, and border details — box_cex for symbol spacing, NA box placement in horizontal choropleth legends, text overflow when no_data is set. The shared vocabulary with mapsf is being maintained deliberately, with val_rnd, val_big, and val_dec propagating through legend types release by release. Version numbering is not monotonic in this feed, with 0.4.0 published seconds after 0.5.0.
Prediction
Expect the remaining combined map types to acquire matching legends and the val_* formatting arguments to reach the types that still lack them.

Recent moves

  1. 2mo ago

    Continuous legend formatting and aspect-ratio segment fix

    Extends val_big and val_dec to continuous legends and corrects segment size for proportional legends when the aspect ratio is not 1 — the same asp != 1 class of bug the 0.4.0 refactor was meant to close. The rest is test hygiene around recordGraphics().

    View source ↗
  2. 4mo ago

    Choropleth legends on points, lines and symbols

    Adds choro_point, choro_line, and choro_symb legend types so choropleth classes can be shown on circles, squares, lines, or symbols rather than boxes alone, plus a val_max argument for pinning proportional symbol maximum size to a chosen value. A long list of spacing and border fixes accompanies them, including text overflow with symb legends when no_data is enabled.

    View source ↗
  3. 7mo ago

    Package-wide refactor for non-unity aspect ratios, histogram legends

    Refactors most of the package for robust behavior when the plot aspect ratio is not 1, which had been a persistent source of misplacement, and adds a histo legend type for histogram legends. Introduces val_big and val_dec alongside the existing val_rnd for separator control.

    View source ↗
  4. 7mo ago

    Single-modality legends allowed for typo, symb and prop_line

    Permits legends with only one modality for the typo, symb, and prop_line types, which previously errored. Published seconds before 0.4.0 despite the higher version number, so the feed ordering here does not reflect release order.

    View source ↗
  5. 1y ago

    Alpha transparency and redraw on device resize

    Adds alpha transparency across all legend types and makes legends redraw when the plot device is resized, matching the same change in mapsf 1.0.0 released the same day. The resize behavior is what makes these legends usable in IDE graphics panes.

    View source ↗
  6. 1y ago

    Offset and symbol sizing aligned with mapsf

    Adopts mapsf's quarter-line offset convention and improves symbol sizing and box offsets for the symb and typo types, plus alpha transparency for palettes. Adds a NEWS.md file, which is why this feed has entries at all.

    View source ↗