from spotforecast2.plots.style import assign_colors
palette = assign_colors(
["team_a", "team_b", "baseline"], ["team_a", "baseline"]
)
print(palette["team_a"], palette["team_b"])#2a78d6 #52514e
plots.style
Print-oriented styling parameters for the plots modules.
The values here are the ones the spot* manuscripts render with. They are offered as plain data and as one dict-returning helper, never as a side effect: importing this module changes nothing, and no plotting function in spotforecast2.plots reads it. Applying a theme stays an explicit act of the caller, which is what keeps the plot functions composable with a caller’s own styling.
import matplotlib.pyplot as plt
from spotforecast2.plots.style import paper_rc
plt.rcParams.update(paper_rc())
Three separate jobs are served by three separate groups below, and they are not interchangeable. The ink tokens are chrome, the categorical hues carry entity identity, and the sequential ramp encodes magnitude.
| Name | Description |
|---|---|
| CATEGORICAL | Fixed-order hues for entities a figure singles out. |
| GRID | Grid lines and neutral fills such as range bands. |
| INK | Primary text and axis labels. |
| INK_MUTED | Secondary text: tick labels, captions, de-emphasised entries. |
| RULE | Axes edges and spines. |
| SEQUENTIAL_BLUE | One hue, light to dark, for encoding magnitude. |
| Name | Description |
|---|---|
| assign_colors | Map every entry to a color, singling out highlight. |
| paper_rc | Return matplotlib.rcParams overrides for the print look. |
Map every entry to a color, singling out highlight.
Entries named in highlight take the categorical hues in the order they are listed, and every other entry takes base. Passing a mapping instead pins chosen entries to chosen colors, which is what a document wants when one entity should keep its color across figures that contain different entries.
| Name | Type | Description | Default |
|---|---|---|---|
| entries | Iterable[str] | Entry ids appearing in the figure. | required |
| highlight | Iterable[str] | Mapping[str, str] | Either entry ids to draw from CATEGORICAL in order, or a mapping of entry id to an explicit color. |
() |
| base | str | Color for entries not highlighted. | INK_MUTED |
| Name | Type | Description |
|---|---|---|
| dict[str, str] | A mapping of every entry id to a color. |
| Name | Type | Description |
|---|---|---|
| ValueError | If more entries are highlighted than CATEGORICAL has hues. |
Return matplotlib.rcParams overrides for the print look.
The caller applies them, typically once per document: plt.rcParams.update(paper_rc()). Nothing in this package applies them implicitly.
| Name | Type | Description | Default |
|---|---|---|---|
| dpi | float | Resolution for both on-screen figures and saved files. | 200 |
| font_size | float | Base font size in points. Tick and label sizes that a plot function sets explicitly are unaffected. | 8.5 |
| Name | Type | Description |
|---|---|---|
| dict[str, object] | A mapping suitable for matplotlib.rcParams.update. |