matplotlib-map-utils 4.0.0__tar.gz → 4.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {matplotlib_map_utils-4.0.0/matplotlib_map_utils.egg-info → matplotlib_map_utils-4.1.0}/PKG-INFO +6 -3
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/README.md +4 -2
- {matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/index/generator_map.py +2 -2
- {matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/inset_maps/generator.py +26 -27
- {matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/north_arrows/generator.py +3 -5
- {matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/quick/generator.py +6 -6
- {matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/scale_bars/generator.py +7 -10
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/__init__.py +16 -4
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/config.py +4 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/core/inset_map.py +192 -238
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/core/north_arrow.py +99 -136
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/core/scale_bar.py +116 -187
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/defaults/__init__.py +3 -3
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/defaults/inset_map.py +5 -5
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/defaults/north_arrow.py +204 -0
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/defaults/scale_bar.py +156 -0
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/validation/inset_map.py +74 -0
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/validation/north_arrow.py +177 -0
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/validation/scale_bar.py +237 -0
- matplotlib_map_utils-4.1.0/matplotlib_map_utils/validation/shared.py +66 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0/matplotlib_map_utils.egg-info}/PKG-INFO +6 -3
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils.egg-info/SOURCES.txt +2 -1
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils.egg-info/requires.txt +1 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/pyproject.toml +3 -2
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/defaults/north_arrow.py +0 -416
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/defaults/scale_bar.py +0 -407
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/validation/functions.py +0 -264
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/validation/inset_map.py +0 -91
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/validation/north_arrow.py +0 -176
- matplotlib_map_utils-4.0.0/matplotlib_map_utils/validation/scale_bar.py +0 -285
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/LICENSE +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/docs/assets/index/generator_logo.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/core/__init__.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/scratch/map_utils.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/scratch/north_arrow_old_classes.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/utils/__init__.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/utils/usa.json +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/utils/usa.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils/validation/__init__.py +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils.egg-info/dependency_links.txt +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/matplotlib_map_utils.egg-info/top_level.txt +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/setup.cfg +0 -0
- {matplotlib_map_utils-4.0.0 → matplotlib_map_utils-4.1.0}/site/assets/index/generator_logo.py +0 -0
- {matplotlib_map_utils-4.0.0/docs → matplotlib_map_utils-4.1.0/site}/assets/index/generator_map.py +0 -0
- {matplotlib_map_utils-4.0.0/docs → matplotlib_map_utils-4.1.0/site}/assets/inset_maps/generator.py +0 -0
- {matplotlib_map_utils-4.0.0/docs → matplotlib_map_utils-4.1.0/site}/assets/north_arrows/generator.py +0 -0
- {matplotlib_map_utils-4.0.0/docs → matplotlib_map_utils-4.1.0/site}/assets/quick/generator.py +0 -0
- {matplotlib_map_utils-4.0.0/docs → matplotlib_map_utils-4.1.0/site}/assets/scale_bars/generator.py +0 -0
{matplotlib_map_utils-4.0.0/matplotlib_map_utils.egg-info → matplotlib_map_utils-4.1.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: matplotlib-map-utils
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: A suite of tools for creating maps in matplotlib
|
|
5
5
|
Author-email: David Moss <davidmoss1221@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/moss-xyz/matplotlib-map-utils/
|
|
@@ -15,6 +15,7 @@ License-File: LICENSE
|
|
|
15
15
|
Requires-Dist: matplotlib>=3.9.0
|
|
16
16
|
Requires-Dist: cartopy>=0.23.0
|
|
17
17
|
Requires-Dist: great-circle-calculator>=1.3.1
|
|
18
|
+
Requires-Dist: pydantic>=2.13.3
|
|
18
19
|
Dynamic: license-file
|
|
19
20
|
|
|
20
21
|

|
|
@@ -27,7 +28,7 @@ Dynamic: license-file
|
|
|
27
28
|
|
|
28
29
|
**Feedback:** I welcome any and all feedback! See the *Development Notes* below for more details.
|
|
29
30
|
|
|
30
|
-
**Current Version:** `v4.
|
|
31
|
+
**Current Version:** `v4.1.0`, featuring a brand-new documentation site and improved type validation! This DID introduce some breaking changes, see the documentation site for details!
|
|
31
32
|
|
|
32
33
|
---
|
|
33
34
|
|
|
@@ -35,7 +36,7 @@ Dynamic: license-file
|
|
|
35
36
|
|
|
36
37
|
`matplotlib_map_utils` is a package that that assists with the creation of maps using [`matplotlib`](https://matplotlib.org/stable/).
|
|
37
38
|
|
|
38
|
-
As of `
|
|
39
|
+
As of `v4.x` (the current version), this includes the ability to easily create three common map elements:
|
|
39
40
|
|
|
40
41
|
* <span style="color: orange; font-weight: bold;">North arrows</span>, which automatically point to true north,
|
|
41
42
|
|
|
@@ -73,6 +74,8 @@ The requirements for this package are:
|
|
|
73
74
|
|
|
74
75
|
* `cartopy >= 0.23` (due to earlier bug with calling `copy()` on `CRS` objects)
|
|
75
76
|
|
|
77
|
+
* `pydantic >= 2.13.3` (for type validation; might work with older versions, open an issue if you have questions)
|
|
78
|
+
|
|
76
79
|
---
|
|
77
80
|
|
|
78
81
|
### Quick Start and Usage Guides
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
**Feedback:** I welcome any and all feedback! See the *Development Notes* below for more details.
|
|
10
10
|
|
|
11
|
-
**Current Version:** `v4.
|
|
11
|
+
**Current Version:** `v4.1.0`, featuring a brand-new documentation site and improved type validation! This DID introduce some breaking changes, see the documentation site for details!
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
`matplotlib_map_utils` is a package that that assists with the creation of maps using [`matplotlib`](https://matplotlib.org/stable/).
|
|
18
18
|
|
|
19
|
-
As of `
|
|
19
|
+
As of `v4.x` (the current version), this includes the ability to easily create three common map elements:
|
|
20
20
|
|
|
21
21
|
* <span style="color: orange; font-weight: bold;">North arrows</span>, which automatically point to true north,
|
|
22
22
|
|
|
@@ -54,6 +54,8 @@ The requirements for this package are:
|
|
|
54
54
|
|
|
55
55
|
* `cartopy >= 0.23` (due to earlier bug with calling `copy()` on `CRS` objects)
|
|
56
56
|
|
|
57
|
+
* `pydantic >= 2.13.3` (for type validation; might work with older versions, open an issue if you have questions)
|
|
58
|
+
|
|
57
59
|
---
|
|
58
60
|
|
|
59
61
|
### Quick Start and Usage Guides
|
{matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/index/generator_map.py
RENAMED
|
@@ -35,14 +35,14 @@ georgia.buffer(75000).plot(ax=ax, facecolor="none", edgecolor="none") # this hel
|
|
|
35
35
|
georgia.plot(ax=ax, edgecolor="black", facecolor="none")
|
|
36
36
|
|
|
37
37
|
# Creating an inset map and extent indicator for the USA
|
|
38
|
-
cax = inset_map(ax, "lower right",
|
|
38
|
+
cax = inset_map(ax, location="lower right", imsize=1.75, pad=0.1, xticks=[], yticks=[])
|
|
39
39
|
contiguous.plot(ax=cax, facecolor="none", edgecolor="black", linewidth=0.5)
|
|
40
40
|
indicate_extent(cax, ax, 3857, 3857)
|
|
41
41
|
|
|
42
42
|
# Creating an inset map and detail indicator for Atlanta, GA
|
|
43
43
|
atl_centroid = shapely.Point(pyproj.Transformer.from_crs(4326, 3857, always_xy=True).transform(-84.40123859860549, 33.75203795433787))
|
|
44
44
|
atl_buffer = atl_centroid.buffer(20000)
|
|
45
|
-
aax = inset_map(ax, "upper right",
|
|
45
|
+
aax = inset_map(ax, location="upper right", imsize=1.75, pad=0.25, xticks=[], yticks=[])
|
|
46
46
|
geopandas.GeoSeries(atl_buffer).plot(ax=aax, facecolor="none", edgecolor="none")
|
|
47
47
|
indicate_detail(ax, aax, 3857, 3857, linecolor="cornflowerblue")
|
|
48
48
|
|
{matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/inset_maps/generator.py
RENAMED
|
@@ -37,6 +37,7 @@ hawaii = states.query(f"GEOID == '{usa.filter_abbr("HI")}'").to_crs(4135)
|
|
|
37
37
|
hawaii.geometry = [shapely.MultiPolygon([g for g in hawaii.iloc[0].geometry.geoms if g.area>1e-3])]
|
|
38
38
|
|
|
39
39
|
from matplotlib_map_utils import InsetMap, inset_map, ExtentIndicator, indicate_extent, DetailIndicator, indicate_detail
|
|
40
|
+
from matplotlib_map_utils import config
|
|
40
41
|
|
|
41
42
|
#------------------------------------------------
|
|
42
43
|
# usa_w_alaska_func.png
|
|
@@ -48,7 +49,7 @@ fig, ax = new_map()
|
|
|
48
49
|
contiguous.plot(ax=ax)
|
|
49
50
|
|
|
50
51
|
# Adding an inset map to the plot
|
|
51
|
-
iax = inset_map(ax, location="lower left",
|
|
52
|
+
iax = inset_map(ax, location="lower left", imsize=0.8, pad=0.1, xticks=[], yticks=[])
|
|
52
53
|
# Plotting alaska in the inset map
|
|
53
54
|
alaska.plot(ax=iax)
|
|
54
55
|
|
|
@@ -67,7 +68,7 @@ contiguous.plot(ax=ax)
|
|
|
67
68
|
# Creating an InsetMap object that we want to place in the lower-right corner of the axis,
|
|
68
69
|
# Note that here, we do not specify the "parent" axis (ax)
|
|
69
70
|
# Note that we also tell it what data we are going to want to plot there, but this is optional!
|
|
70
|
-
im = InsetMap("lower left",
|
|
71
|
+
im = InsetMap("lower left", imsize=0.8, pad=0.1, to_plot={"data":hawaii}, xticks=[], yticks=[])
|
|
71
72
|
# The InsetMap can then be added using create()
|
|
72
73
|
# Note that this is DIFFERENT than NorthArrow and ScaleBar objects, which rely on add_artist()!
|
|
73
74
|
iax = im.create(ax)
|
|
@@ -88,7 +89,7 @@ for ax,l in zip(axs.flatten(), locs):
|
|
|
88
89
|
ax.set_aspect(1, adjustable="datalim") # this is just making things square-ish for us
|
|
89
90
|
ax.set_title(l)
|
|
90
91
|
# Creating the inset map at our specified location
|
|
91
|
-
inset_map(ax=ax, location=l,
|
|
92
|
+
inset_map(ax=ax, location=l, imsize=0.5, pad=0.05, xticks=[], yticks=[])
|
|
92
93
|
|
|
93
94
|
matplotlib.pyplot.savefig("./location_grid.png", bbox_inches="tight")
|
|
94
95
|
matplotlib.pyplot.close()
|
|
@@ -99,9 +100,9 @@ matplotlib.pyplot.close()
|
|
|
99
100
|
|
|
100
101
|
# Changing size and padding
|
|
101
102
|
modifications = [
|
|
102
|
-
{"
|
|
103
|
-
{"
|
|
104
|
-
{"
|
|
103
|
+
{"imsize":0.25,"pad":0},
|
|
104
|
+
{"imsize":0.5,"pad":0},
|
|
105
|
+
{"imsize":0.25, "pad":0.25},
|
|
105
106
|
]
|
|
106
107
|
fig, axs = new_map(1,3, figsize=(9,3))
|
|
107
108
|
for ax,l,m in zip(axs.flatten(), locs, modifications):
|
|
@@ -124,7 +125,7 @@ fig, axs = new_map(1,2, figsize=(10,5))
|
|
|
124
125
|
for ax,z in zip(axs.flatten(), zorders):
|
|
125
126
|
states.query(f"NAME=='Georgia'").plot(ax=ax, zorder=z["plot"])
|
|
126
127
|
ax.set_aspect(1, adjustable="datalim")
|
|
127
|
-
inset_map(ax=ax, location="upper left",
|
|
128
|
+
inset_map(ax=ax, location="upper left", imsize=1, pad=0.05, xticks=[], yticks=[], zorder=z["inset"])
|
|
128
129
|
|
|
129
130
|
matplotlib.pyplot.savefig("./zorder.png", bbox_inches="tight")
|
|
130
131
|
matplotlib.pyplot.close()
|
|
@@ -139,11 +140,11 @@ for ax,l,m in zip(axs.flatten(), locs, modifications):
|
|
|
139
140
|
ax.set_aspect(1, adjustable="datalim") # this is just making things square-ish for us
|
|
140
141
|
|
|
141
142
|
# First, a default for comparison
|
|
142
|
-
inset_map(ax=axs[0], location="upper right",
|
|
143
|
+
inset_map(ax=axs[0], location="upper right", imsize=0.8, pad=0.05, xticks=[], yticks=[])
|
|
143
144
|
# Placing the upper right corner of the inset axes in the middle of the map
|
|
144
|
-
inset_map(ax=axs[1], location="upper right",
|
|
145
|
+
inset_map(ax=axs[1], location="upper right", imsize=0.8, pad=0.05, coords=(0.5,0.5), xticks=[], yticks=[])
|
|
145
146
|
# Placing the upper left corner of the inset axes on Atlanta, GA, using ax.transData
|
|
146
|
-
inset_map(ax=axs[2], location="upper left",
|
|
147
|
+
inset_map(ax=axs[2], location="upper left", imsize=0.8, pad=0.05, coords=(-9353446,4007500), transform=axs[2].transData, xticks=[], yticks=[])
|
|
147
148
|
|
|
148
149
|
matplotlib.pyplot.savefig("./locations.png", bbox_inches="tight")
|
|
149
150
|
matplotlib.pyplot.close()
|
|
@@ -156,7 +157,7 @@ matplotlib.pyplot.close()
|
|
|
156
157
|
# One common use-case for this would be displaying a map of the US as you plot multiple individual US states
|
|
157
158
|
|
|
158
159
|
# Defining the inset map
|
|
159
|
-
im = InsetMap("lower left",
|
|
160
|
+
im = InsetMap("lower left", imsize=0.8, pad=0.05, xticks=[], yticks=[],
|
|
160
161
|
to_plot=[{"data":contiguous, "kwargs":{"facecolor":"red"}}])
|
|
161
162
|
|
|
162
163
|
# Creating 1x3 subplots
|
|
@@ -186,7 +187,7 @@ fig, ax = new_map()
|
|
|
186
187
|
contiguous.plot(ax=ax)
|
|
187
188
|
|
|
188
189
|
# Adding an inset map to the plot with some kwargs for xticks, yticks, and facecolor
|
|
189
|
-
iax = inset_map(ax, location="lower left",
|
|
190
|
+
iax = inset_map(ax, location="lower left", imsize=0.8, pad=0.1, xticks=[], yticks=[], facecolor="red")
|
|
190
191
|
# Plotting alaska in the inset map
|
|
191
192
|
alaska.plot(ax=iax)
|
|
192
193
|
|
|
@@ -204,9 +205,9 @@ contiguous.plot(ax=ax)
|
|
|
204
205
|
|
|
205
206
|
# Adding multiple inset maps to the plot
|
|
206
207
|
# Also using facecolor so you can see which is which
|
|
207
|
-
iax = inset_map(ax, location="lower left",
|
|
208
|
-
iax = inset_map(ax, location="lower right",
|
|
209
|
-
iax = inset_map(ax, location="center right",
|
|
208
|
+
iax = inset_map(ax, location="lower left", imsize=0.25, pad=0.1, xticks=[], yticks=[], facecolor="red")
|
|
209
|
+
iax = inset_map(ax, location="lower right", imsize=0.25, pad=0.1, xticks=[], yticks=[], facecolor="blue")
|
|
210
|
+
iax = inset_map(ax, location="center right", imsize=0.25, pad=0.1, xticks=[], yticks=[], facecolor="green")
|
|
210
211
|
|
|
211
212
|
matplotlib.pyplot.savefig("./multiple_insets.png", bbox_inches="tight")
|
|
212
213
|
matplotlib.pyplot.close()
|
|
@@ -224,7 +225,7 @@ contiguous.plot(ax=ax)
|
|
|
224
225
|
|
|
225
226
|
# Creating all the axes at once
|
|
226
227
|
# Note that each of the 4 states can be turned off individually!
|
|
227
|
-
aax, hax, pax, dax = inset_usa(ax, alaska=True, hawaii=True, dc=True, puerto_rico=True,
|
|
228
|
+
aax, hax, pax, dax = inset_usa(ax, alaska=True, hawaii=True, dc=True, puerto_rico=True, imsize=0.4, pad=0.05, xticks=[], yticks=[], box_aspect=1)
|
|
228
229
|
|
|
229
230
|
alaska.plot(ax=aax)
|
|
230
231
|
hawaii.plot(ax=hax)
|
|
@@ -249,7 +250,7 @@ contiguous.plot(ax=ax, column="ALAND", edgecolor="black", linewidth=0.5,
|
|
|
249
250
|
# Adding an axis to handle a graph below
|
|
250
251
|
# Don't worry too much about this code, it is quite messy and could be done better, but it should illustrate what is possible
|
|
251
252
|
jenks_land = mapclassify.FisherJenks(contiguous["ALAND"], k=5)
|
|
252
|
-
gax = inset_map(ax, location="lower left",
|
|
253
|
+
gax = inset_map(ax, location="lower left", imsize=(1.1,0.3), pad=(0.25,0.5))
|
|
253
254
|
gax.tick_params(labelsize=4)
|
|
254
255
|
gax.bar(x=range(5), height=jenks_land.counts, color=matplotlib.colormaps["Blues"]([0,0.25,0.50,0.75,1]),
|
|
255
256
|
tick_label=["{:.0e}".format(b) for b in jenks_land.bins], edgecolor="black", linewidth=0.5)
|
|
@@ -265,13 +266,11 @@ matplotlib.pyplot.close()
|
|
|
265
266
|
fig, ax = new_map(1,1, figsize=(10,5))
|
|
266
267
|
# Visualizing three different sizes at various positions
|
|
267
268
|
for s,l in zip(["xs","sm","md"], ["center left", "center", "center right"]):
|
|
268
|
-
#
|
|
269
|
-
|
|
270
|
-
InsetMap.set_size(size=s)
|
|
271
|
-
inset_map(ax=ax, location=l, xticks=[], yticks=[])
|
|
269
|
+
# Using the size parameter directly to control the default profile
|
|
270
|
+
inset_map(ax=ax, location=l, size=s, xticks=[], yticks=[])
|
|
272
271
|
|
|
273
272
|
# Resetting the sizes
|
|
274
|
-
|
|
273
|
+
config.DEFAULT_SIZE = "sm"
|
|
275
274
|
|
|
276
275
|
matplotlib.pyplot.savefig("./set_size.png", bbox_inches="tight")
|
|
277
276
|
matplotlib.pyplot.close()
|
|
@@ -281,7 +280,7 @@ matplotlib.pyplot.close()
|
|
|
281
280
|
#------------------------------------------------
|
|
282
281
|
|
|
283
282
|
# Defining the inset map
|
|
284
|
-
im = InsetMap("upper right",
|
|
283
|
+
im = InsetMap("upper right", imsize=1, pad=0.05, xticks=[], yticks=[], to_plot=[{"data":contiguous}])
|
|
285
284
|
|
|
286
285
|
# Creating a plot of Georgia
|
|
287
286
|
fig, ax = new_map(1,1, figsize=(5,5))
|
|
@@ -301,7 +300,7 @@ matplotlib.pyplot.close()
|
|
|
301
300
|
#------------------------------------------------
|
|
302
301
|
|
|
303
302
|
# Setting up an inset map
|
|
304
|
-
im = InsetMap(location="upper right",
|
|
303
|
+
im = InsetMap(location="upper right", imsize=0.75, pad=0.05, xticks=[], yticks=[], to_plot=[{"data":contiguous}])
|
|
305
304
|
# What will be changed for each extent indicator
|
|
306
305
|
modifications = [
|
|
307
306
|
{}, # default for comparison
|
|
@@ -327,7 +326,7 @@ matplotlib.pyplot.close()
|
|
|
327
326
|
#------------------------------------------------
|
|
328
327
|
|
|
329
328
|
# Defining the inset map, which will be of Washington, DC (!)
|
|
330
|
-
im = InsetMap("lower right",
|
|
329
|
+
im = InsetMap("lower right", imsize=0.5, pad=0.05, xticks=[], yticks=[], to_plot=[{"data":washington_dc}])
|
|
331
330
|
|
|
332
331
|
# Creating a plot of the contiguous US
|
|
333
332
|
fig, ax = new_map(1,1, figsize=(5,5))
|
|
@@ -348,7 +347,7 @@ matplotlib.pyplot.close()
|
|
|
348
347
|
#------------------------------------------------
|
|
349
348
|
|
|
350
349
|
# The code below is the same, except for the very last function
|
|
351
|
-
im = InsetMap("lower right",
|
|
350
|
+
im = InsetMap("lower right", imsize=0.5, pad=0.05, xticks=[], yticks=[], to_plot=[{"data":washington_dc}])
|
|
352
351
|
|
|
353
352
|
fig, ax = new_map(1,1, figsize=(5,5))
|
|
354
353
|
contiguous.plot(ax=ax)
|
|
@@ -366,7 +365,7 @@ matplotlib.pyplot.close()
|
|
|
366
365
|
#------------------------------------------------
|
|
367
366
|
|
|
368
367
|
# Setting up an inset map
|
|
369
|
-
im = InsetMap("lower left",
|
|
368
|
+
im = InsetMap("lower left", imsize=0.5, pad=0.05, xticks=[], yticks=[], to_plot=[{"data":states.query("NAME=='Georgia'")}])
|
|
370
369
|
|
|
371
370
|
# What will be changed for each extent indicator
|
|
372
371
|
modifications = [
|
{matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/north_arrows/generator.py
RENAMED
|
@@ -316,9 +316,8 @@ fig, ax = new_map(1,1, figsize=(10,5))
|
|
|
316
316
|
|
|
317
317
|
# Visualizing the different sizes at various positions
|
|
318
318
|
for l,s in zip([0.1, 0.2, 0.35, 0.55, 0.85], ["xs","sm","md","lg","xl"]):
|
|
319
|
-
#
|
|
320
|
-
|
|
321
|
-
north_arrow(ax=ax, location="center", label={"text":s}, rotation={"degrees":0}, aob={"bbox_to_anchor":(l, 0.5), "bbox_transform":ax.transAxes})
|
|
319
|
+
# Using the size parameter to set the size directly
|
|
320
|
+
north_arrow(ax=ax, size=s, location="center", label={"text":s}, rotation={"degrees":0}, aob={"bbox_to_anchor":(l, 0.5), "bbox_transform":ax.transAxes})
|
|
322
321
|
|
|
323
322
|
matplotlib.pyplot.savefig("./set_size.png", bbox_inches="tight")
|
|
324
323
|
matplotlib.pyplot.close()
|
|
@@ -328,9 +327,8 @@ matplotlib.pyplot.close()
|
|
|
328
327
|
#------------------------------------------------
|
|
329
328
|
|
|
330
329
|
fig, ax = new_map()
|
|
331
|
-
NorthArrow.set_size(size="sm")
|
|
332
330
|
states.query("NAME=='Georgia'").plot(ax=ax)
|
|
333
|
-
north_arrow(ax=ax, location="upper
|
|
331
|
+
north_arrow(ax=ax, size="sm", location="upper left", rotation={"degrees":0}, aob={"bbox_to_anchor":(1.05,1), "bbox_transform":ax.transAxes})
|
|
334
332
|
|
|
335
333
|
matplotlib.pyplot.savefig("./external_placement.png")
|
|
336
334
|
matplotlib.pyplot.close()
|
{matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/quick/generator.py
RENAMED
|
@@ -85,13 +85,13 @@ matplotlib.pyplot.close()
|
|
|
85
85
|
|
|
86
86
|
fig, ax = new_map(1,2, figsize=(10,5))
|
|
87
87
|
# Changing the size
|
|
88
|
-
ScaleBar.set_size(
|
|
88
|
+
# ScaleBar.set_size() is no longer needed
|
|
89
89
|
# Plotting a state (Georgia)
|
|
90
90
|
states.query("NAME=='Georgia'").to_crs(3520).plot(ax=ax[0])
|
|
91
91
|
states.query("NAME=='Georgia'").to_crs(3520).plot(ax=ax[1])
|
|
92
92
|
# Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
|
|
93
|
-
scale_bar(ax=ax[0], location="upper right", style="boxes", bar={"projection":3520})
|
|
94
|
-
scale_bar(ax=ax[1], location="upper right", style="ticks", bar={"projection":3520})
|
|
93
|
+
scale_bar(ax=ax[0], location="upper right", size="sm", style="boxes", bar={"projection":3520})
|
|
94
|
+
scale_bar(ax=ax[1], location="upper right", size="sm", style="ticks", bar={"projection":3520})
|
|
95
95
|
|
|
96
96
|
matplotlib.pyplot.savefig("./scale_bar_generic.png", bbox_inches="tight")
|
|
97
97
|
matplotlib.pyplot.close()
|
|
@@ -123,7 +123,7 @@ fig, ax = new_map(1,1, figsize=(5,5))
|
|
|
123
123
|
# Plotting a state (Georgia)
|
|
124
124
|
states.query("NAME=='Georgia'").to_crs(3520).plot(ax=ax)
|
|
125
125
|
# Adding an inset map to the upper-right corner of the axis
|
|
126
|
-
iax = inset_map(ax=ax, location="upper right",
|
|
126
|
+
iax = inset_map(ax=ax, location="upper right", imsize=0.75, pad=0.25, xticks=[], yticks=[])
|
|
127
127
|
|
|
128
128
|
matplotlib.pyplot.savefig("./inset_map_generic.png", bbox_inches="tight")
|
|
129
129
|
matplotlib.pyplot.close()
|
|
@@ -137,8 +137,8 @@ fig, ax = new_map(1,2, figsize=(10,5))
|
|
|
137
137
|
states.query("NAME=='Georgia'").to_crs(3520).plot(ax=ax[0])
|
|
138
138
|
states.query("NAME=='Georgia'").to_crs(3520).plot(ax=ax[1])
|
|
139
139
|
# Adding an inset map to the upper-right corner of the axis
|
|
140
|
-
iax0 = inset_map(ax=ax[0], location="upper right",
|
|
141
|
-
iax1 = inset_map(ax=ax[1], location="upper right",
|
|
140
|
+
iax0 = inset_map(ax=ax[0], location="upper right", imsize=1, pad=0.25, xticks=[], yticks=[])
|
|
141
|
+
iax1 = inset_map(ax=ax[1], location="upper right", imsize=0.75, pad=0.25, xticks=[], yticks=[])
|
|
142
142
|
# Adding an extent indicator for the map on the left
|
|
143
143
|
contiguous.plot(ax=iax0, facecolor="none", edgecolor="black", linewidth=0.5)
|
|
144
144
|
indicate_extent(iax0, ax[0], 3857, 3520, pad=0.25)
|
{matplotlib_map_utils-4.0.0/site → matplotlib_map_utils-4.1.0/docs}/assets/scale_bars/generator.py
RENAMED
|
@@ -142,8 +142,8 @@ matplotlib.pyplot.close()
|
|
|
142
142
|
# locations.png
|
|
143
143
|
#------------------------------------------------
|
|
144
144
|
|
|
145
|
-
# Do not worry about this: it is covered later, it is simply updating the default size of the scale bar
|
|
146
|
-
ScaleBar.set_size(
|
|
145
|
+
# Do not worry about this: it is covered later, it is simply updating the default size of the scale bar to xs
|
|
146
|
+
# ScaleBar.set_size() is no longer needed — pass size= directly instead
|
|
147
147
|
# Grid of location options
|
|
148
148
|
# Note that the "center" options will feel slightly off: this is because the the center of the scale bar is of the entire artist, text included, not just the bar itself
|
|
149
149
|
locs = ["upper left", "upper center", "upper right", "center left", "center", "center right", "lower left", "lower center", "lower right"]
|
|
@@ -151,7 +151,7 @@ fig, axs = new_map(3,3, figsize=(9,9))
|
|
|
151
151
|
for ax,l in zip(axs.flatten(), locs):
|
|
152
152
|
states.query(f"NAME=='Georgia'").plot(ax=ax)
|
|
153
153
|
ax.set_aspect(1, adjustable="datalim")
|
|
154
|
-
scale_bar(ax=ax, location=l, style="boxes", bar={"projection":3857,"minor_type":"none"}, labels={"style":"first_last"})
|
|
154
|
+
scale_bar(ax=ax, size="xs", location=l, style="boxes", bar={"projection":3857,"minor_type":"none"}, labels={"style":"first_last"})
|
|
155
155
|
|
|
156
156
|
matplotlib.pyplot.savefig("./locations.png", bbox_inches="tight")
|
|
157
157
|
matplotlib.pyplot.close()
|
|
@@ -161,7 +161,7 @@ matplotlib.pyplot.close()
|
|
|
161
161
|
#------------------------------------------------
|
|
162
162
|
|
|
163
163
|
# Just reverting the change I made above; again this is explained later, don't worry about it for now
|
|
164
|
-
|
|
164
|
+
# (No longer needed: we pass size= directly now)
|
|
165
165
|
# Modifying the styles
|
|
166
166
|
styles = ["boxes","ticks"]
|
|
167
167
|
# Creating 1x2 subplots
|
|
@@ -401,7 +401,6 @@ matplotlib.pyplot.close()
|
|
|
401
401
|
#------------------------------------------------
|
|
402
402
|
|
|
403
403
|
# Modifying specific elements
|
|
404
|
-
ScaleBar.set_size("md")
|
|
405
404
|
|
|
406
405
|
modifications = [
|
|
407
406
|
{"facecolor": "lightgrey"}, # different facecolor
|
|
@@ -454,12 +453,10 @@ states.query(f"NAME=='California'").plot(ax=ax)
|
|
|
454
453
|
# Visualizing three different sizes at various positions
|
|
455
454
|
for s,l in zip(["sm","md","lg"], ["upper center", "center", "lower center"]):
|
|
456
455
|
# Calling the function to update the defaults
|
|
457
|
-
|
|
458
|
-
scale_bar(ax=ax, location=l, style="boxes", labels={"style":"major"},
|
|
456
|
+
scale_bar(ax=ax, size=s, location=l, style="boxes", labels={"style":"major"},
|
|
459
457
|
bar={"projection":3857,"max":900,"major_div":3,"minor_div":1,"minor_type":"none"})
|
|
460
458
|
|
|
461
|
-
#
|
|
462
|
-
ScaleBar.set_size(size="sm")
|
|
459
|
+
# No need to reset sizes - the size= parameter handles it per-call
|
|
463
460
|
|
|
464
461
|
matplotlib.pyplot.savefig("./set_size.png", bbox_inches="tight")
|
|
465
462
|
matplotlib.pyplot.close()
|
|
@@ -474,7 +471,7 @@ states.query("NAME=='Georgia'").plot(ax=ax)
|
|
|
474
471
|
|
|
475
472
|
scale_bar(ax=ax, location="upper center", style="boxes", labels={"style":"major"},
|
|
476
473
|
bar={"projection":3857,"max":500,"major_div":5,"minor_div":1,"minor_type":"none"},
|
|
477
|
-
aob={"bbox_to_anchor":(0.5,-0.
|
|
474
|
+
aob={"bbox_to_anchor":(0.5,-0.005), "bbox_transform":ax.transAxes})
|
|
478
475
|
|
|
479
476
|
matplotlib.pyplot.savefig("./external_placement.png")
|
|
480
477
|
matplotlib.pyplot.close()
|
|
@@ -10,12 +10,24 @@ __all__ = ["NorthArrow", "north_arrow",
|
|
|
10
10
|
"InsetMap","inset_map", "ExtentIndicator","indicate_extent", "DetailIndicator","indicate_detail", "inset_usa",
|
|
11
11
|
"set_size"]
|
|
12
12
|
|
|
13
|
+
from . import config
|
|
14
|
+
|
|
13
15
|
def set_size(size: Literal["xs","xsmall","x-small",
|
|
14
16
|
"sm","small",
|
|
15
17
|
"md","medium",
|
|
16
18
|
"lg","large",
|
|
17
19
|
"xl","xlarge","x-large"]):
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
# standardize the size string
|
|
22
|
+
size_map = {
|
|
23
|
+
"xs": "xs", "xsmall": "xs", "x-small": "xs",
|
|
24
|
+
"sm": "sm", "small": "sm",
|
|
25
|
+
"md": "md", "medium": "md",
|
|
26
|
+
"lg": "lg", "large": "lg",
|
|
27
|
+
"xl": "xl", "xlarge": "xl", "x-large": "xl"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if size.lower() not in size_map:
|
|
31
|
+
raise ValueError("Invalid value supplied, try one of ['xsmall', 'small', 'medium', 'large', 'xlarge']")
|
|
32
|
+
|
|
33
|
+
config.DEFAULT_SIZE = size_map[size.lower()]
|