Subway signs¶
subway_signs() lays out labeled colored circles. It is a compact district key for maps and
multi-panel reports, especially when a conventional legend would consume too much vertical
space. Pass colors and labels in the same order used by the plan map.
import matplotlib.pyplot as plt
from gerrytools.colors import districtr
from gerrytools.plotting import subway_signs
labels = [str(district) for district in range(1, 15)]
colors = districtr(len(labels))
subway_signs(colors, labels)
plt.show()
The function returns the (Figure, Axes) pair it draws. Pass ax= to reserve a panel for the
key in an existing Matplotlib layout, or filepath= to save it directly. The function does
not infer district labels from a map, so the ordering of the two input sequences is the
complete color-to-label contract.
Layout¶
The default is one horizontal band. orientation= changes the reading direction, while
n_bands= requests a fixed number of rows or columns. max_items_per_band= instead caps the
number of signs in each band and lets the function determine how many bands are required. Use
one of the two band controls, not both. SubwaySignOptions controls circle size, spacing,
border, and text when the default key needs to match a report layout.
subway_signs(colors, labels, orientation="vertical", n_bands=2)
plt.show()