matplotlib-map-utils 1.0.0__py3-none-any.whl
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/__init__.py +4 -0
- matplotlib_map_utils/defaults.py +416 -0
- matplotlib_map_utils/north_arrow.py +458 -0
- matplotlib_map_utils/scratch/map_utils.py +412 -0
- matplotlib_map_utils/scratch/north_arrow_old_classes.py +1185 -0
- matplotlib_map_utils/validation.py +332 -0
- matplotlib_map_utils-1.0.0.dist-info/LICENSE +674 -0
- matplotlib_map_utils-1.0.0.dist-info/METADATA +131 -0
- matplotlib_map_utils-1.0.0.dist-info/RECORD +11 -0
- matplotlib_map_utils-1.0.0.dist-info/WHEEL +5 -0
- matplotlib_map_utils-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,416 @@
|
|
1
|
+
############################################################
|
2
|
+
# defaults.py contains default values for the artists
|
3
|
+
# at difference plot sizes (xsmall to xlarge)
|
4
|
+
# see their corresponding sizes under each default heading
|
5
|
+
############################################################
|
6
|
+
|
7
|
+
# The main variables that update are the following:
|
8
|
+
# base: scale, linewidth
|
9
|
+
# fancy: coords (xsmall only)
|
10
|
+
# label: fontsize, stroke_width
|
11
|
+
# shadow: offset
|
12
|
+
# pack: sep
|
13
|
+
# aob: pad, borderpad
|
14
|
+
|
15
|
+
### IMPORTING PACKAGES ###
|
16
|
+
|
17
|
+
# Math packages
|
18
|
+
import numpy
|
19
|
+
|
20
|
+
### INDEPENDENT DEFAULT VALUES ###
|
21
|
+
|
22
|
+
# Defaults for rotating the arrow to point towards True North (see _rotate_arrow for how it is used)
|
23
|
+
# This default is the only one that is static: the rest can and should change depending on the size of your figure
|
24
|
+
_ROTATION_ALL = {
|
25
|
+
"degrees":None,
|
26
|
+
"crs":None,
|
27
|
+
"reference":None,
|
28
|
+
"coords":None
|
29
|
+
}
|
30
|
+
|
31
|
+
# We also use the same coordinates for the arrow's base, regardless of size
|
32
|
+
# This is because we can scale the arrow larger/smaller using the scale parameter instead
|
33
|
+
_COORDS_BASE = numpy.array([
|
34
|
+
(0.50, 1.00),
|
35
|
+
(0.10, 0.00),
|
36
|
+
(0.50, 0.10),
|
37
|
+
(0.90, 0.00),
|
38
|
+
(0.50, 1.00)
|
39
|
+
])
|
40
|
+
|
41
|
+
# Similarly, we use the same coordinates for the arrows "fancy" part
|
42
|
+
# EXCEPT when it gets too small (x-small), as rasterization makes it difficult to see the white edge
|
43
|
+
_COORDS_FANCY = numpy.array([
|
44
|
+
(0.50, 0.85),
|
45
|
+
(0.50, 0.20),
|
46
|
+
(0.80, 0.10),
|
47
|
+
(0.50, 0.85)
|
48
|
+
])
|
49
|
+
|
50
|
+
_COORDS_FANCY_XS = numpy.array([
|
51
|
+
(0.50, 1.00),
|
52
|
+
(0.50, 0.10),
|
53
|
+
(0.90, 0.00),
|
54
|
+
(0.50, 1.00)
|
55
|
+
])
|
56
|
+
|
57
|
+
## X-SMALL DEFAULTS
|
58
|
+
# Should work well for ~A8ish paper (2 to 3 inches, or 5 to 8 cm)
|
59
|
+
# The arrow will appear to be ~1/10 of an inch in height
|
60
|
+
# Here is also the only place that we use the _COORDS_FANCY_XS array!
|
61
|
+
|
62
|
+
# Scale
|
63
|
+
_SCALE_XS = 0.12
|
64
|
+
|
65
|
+
# Base
|
66
|
+
_BASE_XS = {
|
67
|
+
"coords":_COORDS_BASE,
|
68
|
+
"facecolor":"white",
|
69
|
+
"edgecolor":"black",
|
70
|
+
"linewidth":0.7,
|
71
|
+
"zorder":98
|
72
|
+
}
|
73
|
+
|
74
|
+
# Fancy
|
75
|
+
_FANCY_XS = {
|
76
|
+
"coords":_COORDS_FANCY_XS,
|
77
|
+
"facecolor":"black",
|
78
|
+
"zorder":99
|
79
|
+
}
|
80
|
+
|
81
|
+
# Label
|
82
|
+
_LABEL_XS = {
|
83
|
+
"text":"N",
|
84
|
+
"position":"bottom",
|
85
|
+
"ha":"center",
|
86
|
+
"va":"baseline",
|
87
|
+
"fontsize":6,
|
88
|
+
"fontfamily":"sans-serif",
|
89
|
+
"fontstyle":"normal",
|
90
|
+
"color":"black",
|
91
|
+
"fontweight":"regular",
|
92
|
+
"stroke_width":0.5,
|
93
|
+
"stroke_color":"white",
|
94
|
+
"rotation":0,
|
95
|
+
"zorder":99
|
96
|
+
}
|
97
|
+
|
98
|
+
# Shadow
|
99
|
+
_SHADOW_XS = {
|
100
|
+
"offset":(1,-1),
|
101
|
+
"alpha":0.5,
|
102
|
+
"shadow_rgbFace":"black",
|
103
|
+
}
|
104
|
+
|
105
|
+
# VPacker/HPacker
|
106
|
+
_PACK_XS = {
|
107
|
+
"sep":1.5,
|
108
|
+
"align":"center",
|
109
|
+
"pad":0,
|
110
|
+
"width":None,
|
111
|
+
"height":None,
|
112
|
+
"mode":"fixed"
|
113
|
+
}
|
114
|
+
|
115
|
+
# AnchoredOffsetBox (AOB)
|
116
|
+
_AOB_XS = {
|
117
|
+
"facecolor":None,
|
118
|
+
"edgecolor":None,
|
119
|
+
"alpha":None,
|
120
|
+
"pad":0.2,
|
121
|
+
"borderpad":0.2,
|
122
|
+
"prop":"medium",
|
123
|
+
"frameon":False,
|
124
|
+
"bbox_to_anchor":None,
|
125
|
+
"bbox_transform":None
|
126
|
+
}
|
127
|
+
|
128
|
+
## SMALL DEFAULTS
|
129
|
+
# Should work well for ~A6 paper (4 to 6 inches, or 11 to 15 cm)
|
130
|
+
# The arrow will appear to be ~1/4 of an inch in height
|
131
|
+
|
132
|
+
# Scale
|
133
|
+
_SCALE_SM = 0.25
|
134
|
+
|
135
|
+
# Base
|
136
|
+
_BASE_SM = {
|
137
|
+
"coords":_COORDS_BASE,
|
138
|
+
"facecolor":"white",
|
139
|
+
"edgecolor":"black",
|
140
|
+
"linewidth":0.5,
|
141
|
+
"zorder":98
|
142
|
+
}
|
143
|
+
|
144
|
+
# Fancy
|
145
|
+
_FANCY_SM = {
|
146
|
+
"coords":_COORDS_FANCY,
|
147
|
+
"facecolor":"black",
|
148
|
+
"zorder":99
|
149
|
+
}
|
150
|
+
|
151
|
+
# Label
|
152
|
+
_LABEL_SM = {
|
153
|
+
"text":"N",
|
154
|
+
"position":"bottom",
|
155
|
+
"ha":"center",
|
156
|
+
"va":"baseline",
|
157
|
+
"fontsize":8,
|
158
|
+
"fontfamily":"sans-serif",
|
159
|
+
"fontstyle":"normal",
|
160
|
+
"color":"black",
|
161
|
+
"fontweight":"regular",
|
162
|
+
"stroke_width":0.5,
|
163
|
+
"stroke_color":"white",
|
164
|
+
"rotation":0,
|
165
|
+
"zorder":99
|
166
|
+
}
|
167
|
+
|
168
|
+
# Shadow
|
169
|
+
_SHADOW_SM = {
|
170
|
+
"offset":(2,-2),
|
171
|
+
"alpha":0.5,
|
172
|
+
"shadow_rgbFace":"black",
|
173
|
+
}
|
174
|
+
|
175
|
+
# VPacker/HPacker
|
176
|
+
_PACK_SM = {
|
177
|
+
"sep":3,
|
178
|
+
"align":"center",
|
179
|
+
"pad":0,
|
180
|
+
"width":None,
|
181
|
+
"height":None,
|
182
|
+
"mode":"fixed"
|
183
|
+
}
|
184
|
+
|
185
|
+
# AnchoredOffsetBox (AOB)
|
186
|
+
_AOB_SM = {
|
187
|
+
"facecolor":None,
|
188
|
+
"edgecolor":None,
|
189
|
+
"alpha":None,
|
190
|
+
"pad":0.33,
|
191
|
+
"borderpad":0.33,
|
192
|
+
"prop":"medium",
|
193
|
+
"frameon":False,
|
194
|
+
"bbox_to_anchor":None,
|
195
|
+
"bbox_transform":None
|
196
|
+
}
|
197
|
+
|
198
|
+
## MEDIUM DEFAULTS
|
199
|
+
# Should work well for ~A4/Letter paper (8 to 12 inches, or 21 to 30 cm)
|
200
|
+
# The arrow will appear to be ~ 1/2 an inch or ~1 cm in height
|
201
|
+
|
202
|
+
# Scale
|
203
|
+
_SCALE_MD = 0.50
|
204
|
+
|
205
|
+
# Base
|
206
|
+
_BASE_MD = {
|
207
|
+
"coords":_COORDS_BASE,
|
208
|
+
"facecolor":"white",
|
209
|
+
"edgecolor":"black",
|
210
|
+
"linewidth":1,
|
211
|
+
"zorder":98
|
212
|
+
}
|
213
|
+
|
214
|
+
# Fancy
|
215
|
+
_FANCY_MD = {
|
216
|
+
"coords":_COORDS_FANCY,
|
217
|
+
"facecolor":"black",
|
218
|
+
"zorder":99
|
219
|
+
}
|
220
|
+
|
221
|
+
# Label
|
222
|
+
_LABEL_MD = {
|
223
|
+
"text":"N",
|
224
|
+
"position":"bottom",
|
225
|
+
"ha":"center",
|
226
|
+
"va":"baseline",
|
227
|
+
"fontsize":16,
|
228
|
+
"fontfamily":"sans-serif",
|
229
|
+
"fontstyle":"normal",
|
230
|
+
"color":"black",
|
231
|
+
"fontweight":"regular",
|
232
|
+
"stroke_width":1,
|
233
|
+
"stroke_color":"white",
|
234
|
+
"rotation":0,
|
235
|
+
"zorder":99
|
236
|
+
}
|
237
|
+
|
238
|
+
# Shadow
|
239
|
+
_SHADOW_MD = {
|
240
|
+
"offset":(4,-4),
|
241
|
+
"alpha":0.5,
|
242
|
+
"shadow_rgbFace":"black",
|
243
|
+
}
|
244
|
+
|
245
|
+
# VPacker/HPacker
|
246
|
+
_PACK_MD = {
|
247
|
+
"sep":5,
|
248
|
+
"align":"center",
|
249
|
+
"pad":0,
|
250
|
+
"width":None,
|
251
|
+
"height":None,
|
252
|
+
"mode":"fixed"
|
253
|
+
}
|
254
|
+
|
255
|
+
# AnchoredOffsetBox (AOB)
|
256
|
+
_AOB_MD = {
|
257
|
+
"facecolor":None,
|
258
|
+
"edgecolor":None,
|
259
|
+
"alpha":None,
|
260
|
+
"pad":0.5,
|
261
|
+
"borderpad":0.5,
|
262
|
+
"prop":"medium",
|
263
|
+
"frameon":False,
|
264
|
+
"bbox_to_anchor":None,
|
265
|
+
"bbox_transform":None
|
266
|
+
}
|
267
|
+
|
268
|
+
## LARGE DEFAULTS
|
269
|
+
# Should work well for ~A2 paper (16 to 24 inches, or 42 to 60 cm)
|
270
|
+
# The arrow will appear to be ~an inch in height
|
271
|
+
|
272
|
+
# Scale
|
273
|
+
_SCALE_LG = 1
|
274
|
+
|
275
|
+
# Base
|
276
|
+
_BASE_LG = {
|
277
|
+
"coords":_COORDS_BASE,
|
278
|
+
"facecolor":"white",
|
279
|
+
"edgecolor":"black",
|
280
|
+
"linewidth":2,
|
281
|
+
"zorder":98
|
282
|
+
}
|
283
|
+
|
284
|
+
# Fancy
|
285
|
+
_FANCY_LG = {
|
286
|
+
"coords":_COORDS_FANCY,
|
287
|
+
"facecolor":"black",
|
288
|
+
"zorder":99
|
289
|
+
}
|
290
|
+
|
291
|
+
# Label
|
292
|
+
_LABEL_LG = {
|
293
|
+
"text":"N",
|
294
|
+
"position":"bottom",
|
295
|
+
"ha":"center",
|
296
|
+
"va":"baseline",
|
297
|
+
"fontsize":32,
|
298
|
+
"fontfamily":"sans-serif",
|
299
|
+
"fontstyle":"normal",
|
300
|
+
"color":"black",
|
301
|
+
"fontweight":"regular",
|
302
|
+
"stroke_width":2,
|
303
|
+
"stroke_color":"white",
|
304
|
+
"rotation":0,
|
305
|
+
"zorder":99
|
306
|
+
}
|
307
|
+
|
308
|
+
# Shadow
|
309
|
+
_SHADOW_LG = {
|
310
|
+
"offset":(8,-8),
|
311
|
+
"alpha":0.5,
|
312
|
+
"shadow_rgbFace":"black",
|
313
|
+
}
|
314
|
+
|
315
|
+
# VPacker/HPacker
|
316
|
+
_PACK_LG = {
|
317
|
+
"sep":8,
|
318
|
+
"align":"center",
|
319
|
+
"pad":0,
|
320
|
+
"width":None,
|
321
|
+
"height":None,
|
322
|
+
"mode":"fixed"
|
323
|
+
}
|
324
|
+
|
325
|
+
# AnchoredOffsetBox (AOB)
|
326
|
+
_AOB_LG = {
|
327
|
+
"facecolor":None,
|
328
|
+
"edgecolor":None,
|
329
|
+
"alpha":None,
|
330
|
+
"pad":1,
|
331
|
+
"borderpad":1,
|
332
|
+
"prop":"medium",
|
333
|
+
"frameon":False,
|
334
|
+
"bbox_to_anchor":None,
|
335
|
+
"bbox_transform":None
|
336
|
+
}
|
337
|
+
|
338
|
+
## X-LARGE DEFAULTS
|
339
|
+
# Should work well for ~A0/Poster paper (33 to 47 inches, or 85 to 120 cm)
|
340
|
+
# The arrow will appear to be ~2 inches in height
|
341
|
+
|
342
|
+
# Scale
|
343
|
+
_SCALE_XL = 2
|
344
|
+
|
345
|
+
# Base
|
346
|
+
_BASE_XL = {
|
347
|
+
"coords":_COORDS_BASE,
|
348
|
+
"facecolor":"white",
|
349
|
+
"edgecolor":"black",
|
350
|
+
"linewidth":4,
|
351
|
+
"zorder":98
|
352
|
+
}
|
353
|
+
|
354
|
+
# Fancy
|
355
|
+
_FANCY_XL = {
|
356
|
+
"coords":_COORDS_FANCY,
|
357
|
+
"facecolor":"black",
|
358
|
+
"zorder":99
|
359
|
+
}
|
360
|
+
|
361
|
+
# Label
|
362
|
+
_LABEL_XL = {
|
363
|
+
"text":"N",
|
364
|
+
"position":"bottom",
|
365
|
+
"ha":"center",
|
366
|
+
"va":"baseline",
|
367
|
+
"fontsize":64,
|
368
|
+
"fontfamily":"sans-serif",
|
369
|
+
"fontstyle":"normal",
|
370
|
+
"color":"black",
|
371
|
+
"fontweight":"regular",
|
372
|
+
"stroke_width":4,
|
373
|
+
"stroke_color":"white",
|
374
|
+
"rotation":0,
|
375
|
+
"zorder":99
|
376
|
+
}
|
377
|
+
|
378
|
+
# Shadow
|
379
|
+
_SHADOW_XL = {
|
380
|
+
"offset":(16,-16),
|
381
|
+
"alpha":0.5,
|
382
|
+
"shadow_rgbFace":"black",
|
383
|
+
}
|
384
|
+
|
385
|
+
# VPacker/HPacker
|
386
|
+
_PACK_XL = {
|
387
|
+
"sep":12,
|
388
|
+
"align":"center",
|
389
|
+
"pad":0,
|
390
|
+
"width":None,
|
391
|
+
"height":None,
|
392
|
+
"mode":"fixed"
|
393
|
+
}
|
394
|
+
|
395
|
+
# AnchoredOffsetBox (AOB)
|
396
|
+
_AOB_XL = {
|
397
|
+
"facecolor":None,
|
398
|
+
"edgecolor":None,
|
399
|
+
"alpha":None,
|
400
|
+
"pad":2,
|
401
|
+
"borderpad":2,
|
402
|
+
"prop":"medium",
|
403
|
+
"frameon":False,
|
404
|
+
"bbox_to_anchor":None,
|
405
|
+
"bbox_transform":None
|
406
|
+
}
|
407
|
+
|
408
|
+
## CONTAINER
|
409
|
+
# This makes an easy-to-call dictionary of all the defaults we've set, for easy unpacking by the set_size function
|
410
|
+
_DEFAULT_CONTAINER = {
|
411
|
+
"xs":[_SCALE_XS, _BASE_XS, _FANCY_XS, _LABEL_XS, _SHADOW_XS, _PACK_XS, _AOB_XS],
|
412
|
+
"sm":[_SCALE_SM, _BASE_SM, _FANCY_SM, _LABEL_SM, _SHADOW_SM, _PACK_SM, _AOB_SM],
|
413
|
+
"md":[_SCALE_MD, _BASE_MD, _FANCY_MD, _LABEL_MD, _SHADOW_MD, _PACK_MD, _AOB_MD],
|
414
|
+
"lg":[_SCALE_LG, _BASE_LG, _FANCY_LG, _LABEL_LG, _SHADOW_LG, _PACK_LG, _AOB_LG],
|
415
|
+
"xl":[_SCALE_XL, _BASE_XL, _FANCY_XL, _LABEL_XL, _SHADOW_XL, _PACK_XL, _AOB_XL],
|
416
|
+
}
|