|
52 | 52 |
|
53 | 53 | def plot(
|
54 | 54 | n,
|
55 |
| - margin=None, |
| 55 | + margin=0.05, |
56 | 56 | ax=None,
|
57 | 57 | geomap=True,
|
58 | 58 | projection=None,
|
@@ -83,8 +83,9 @@ def plot(
|
83 | 83 |
|
84 | 84 | Parameters
|
85 | 85 | ----------
|
86 |
| - margin : float |
| 86 | + margin : float, defaults to 0.05 |
87 | 87 | Margin at the sides as proportion of distance between max/min x,y
|
| 88 | + Will be ignored if boundaries are given. |
88 | 89 | ax : matplotlib ax, defaults to plt.gca()
|
89 | 90 | Axis to which to plot the network
|
90 | 91 | geomap: bool/str, default True
|
@@ -160,8 +161,17 @@ def plot(
|
160 | 161 | bus_collection, branch_collection1, ... : tuple of Collections
|
161 | 162 | Collections for buses and branches.
|
162 | 163 | """
|
| 164 | + |
| 165 | + if margin is None: |
| 166 | + logger.warning( |
| 167 | + "The `margin` argument does support None value anymore. " |
| 168 | + "Falling back to the default value 0.05. This will raise " |
| 169 | + "an error in the future." |
| 170 | + ) |
| 171 | + margin = 0.05 |
| 172 | + |
163 | 173 | x, y = _get_coordinates(n, layouter=layouter)
|
164 |
| - if boundaries is None and margin: |
| 174 | + if boundaries is None: |
165 | 175 | boundaries = sum(zip(*compute_bbox_with_margins(margin, x, y)), ())
|
166 | 176 |
|
167 | 177 | if geomap and not cartopy_present:
|
@@ -197,6 +207,8 @@ def plot(
|
197 | 207 | ax.set_extent(boundaries, crs=transform)
|
198 | 208 | elif ax is None:
|
199 | 209 | ax = plt.gca()
|
| 210 | + elif hasattr(ax, "projection"): |
| 211 | + raise ValueError("Axis is a geo axis, but `geomap` is set to False") |
200 | 212 | if not geomap and boundaries:
|
201 | 213 | ax.axis(boundaries)
|
202 | 214 |
|
@@ -388,9 +400,6 @@ def plot(
|
388 | 400 | b_collection.set_zorder(3)
|
389 | 401 | branch_collections.append(b_collection)
|
390 | 402 |
|
391 |
| - if boundaries is None: |
392 |
| - ax.autoscale() |
393 |
| - |
394 | 403 | return (bus_collection,) + tuple(branch_collections) + tuple(arrow_collections)
|
395 | 404 |
|
396 | 405 |
|
|
0 commit comments