Migration from v1 (matplotlib) to v2 (SVG)¶
The import statement is unchanged:
from mappyng import Map
The constructor signature is preserved. The drawing API, however, is now
object-based: instead of m.add_choropleth(gdf, {...}) you build a
layer and add it with m.add(ChoroplethLayer(gdf, ...)). The dict-based
add_* helpers have been removed (see Quickstart).
The parameter names below still apply; they are now keyword arguments of
the corresponding layer class.
Renamed parameters¶
v1 parameter |
v2 parameter |
Notes |
|---|---|---|
|
|
Proportional and situation layers. |
|
|
Proportional and situation layers. |
|
|
Proportional and situation layers. |
|
|
ProportionalLegendConfig. |
|
|
ProportionalLegendConfig. |
|
|
SVG dasharray string instead of matplotlib line style. |
|
|
ProportionalLegendConfig. |
|
|
ProportionalLegendConfig. |
|
|
Legend label decimal places. |
|
|
ChoroplethLayer. |
|
|
ChoroplethLayer. |
Removed parameters¶
These v1 parameters are not available in v2:
v1 parameter |
Reason |
|---|---|
|
v2 proportional symbols are always circles. |
|
Z-order is managed globally by |
|
v2 uses |
|
v2 always uses SVG pixel coordinates. |
PNG custom markers ( |
v2 is SVG-native only. Use custom SVG files instead. |
New parameters in v2¶
These parameters are not present in v1:
Parameter |
Method / class |
Description |
|---|---|---|
|
Global font size multiplier. |
|
|
ProportionalLayer |
Fixed circle radius in SVG px (replaces |
|
ProportionalLegendConfig |
Number of auto-generated legend values. |
|
ProportionalLegendConfig |
Legend circle fill opacity. |
|
SituationLegendConfig |
Multi-column legend layout. |
|
ChoroplethLegendConfig |
SVG hatch pattern for legend swatches. |
|
|
Convenience alias for hover effect opacity. |
|
ChoroplethLegendConfig (horizontal) |
Label centering and range formatting for horizontal legends. |
Tile basemaps¶
v1 used contextily (matplotlib-based). v2 downloads tiles directly:
# v1
import contextily as cx
cx.add_basemap(ax, source=cx.providers.CartoDB.Positron)
# v2
from mappyng import TileLayer
m.add(TileLayer(source="cartodb_positron"))
Requires pip install mappyng[tile].
Label placement¶
v1 used adjustText (matplotlib). v2 uses a pure Python simulated-annealing
implementation with geometric obstacle avoidance:
# v1
m.add_toponyms(gdf, column="nom", max_labels=20)
# v2
from mappyng import LabelLayer
m.add(LabelLayer(gdf, column="nom", max_labels=20, n_sweeps=50))
Exceptions¶
v2 exposes a typed exception hierarchy not present in v1:
from mappyng.errors import MapError, DataError, RenderError