matplotlib-map-utils 3.0.1__py3-none-any.whl → 3.1.1__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/core/inset_map.py +64 -40
- matplotlib_map_utils/core/north_arrow.py +24 -9
- matplotlib_map_utils/core/scale_bar.py +266 -197
- matplotlib_map_utils/defaults/scale_bar.py +5 -0
- matplotlib_map_utils/validation/functions.py +3 -6
- matplotlib_map_utils/validation/inset_map.py +3 -0
- matplotlib_map_utils/validation/north_arrow.py +1 -0
- matplotlib_map_utils/validation/scale_bar.py +7 -4
- matplotlib_map_utils-3.1.1.dist-info/METADATA +1158 -0
- {matplotlib_map_utils-3.0.1.dist-info → matplotlib_map_utils-3.1.1.dist-info}/RECORD +13 -13
- matplotlib_map_utils-3.0.1.dist-info/METADATA +0 -437
- {matplotlib_map_utils-3.0.1.dist-info → matplotlib_map_utils-3.1.1.dist-info}/WHEEL +0 -0
- {matplotlib_map_utils-3.0.1.dist-info → matplotlib_map_utils-3.1.1.dist-info}/licenses/LICENSE +0 -0
- {matplotlib_map_utils-3.0.1.dist-info → matplotlib_map_utils-3.1.1.dist-info}/top_level.txt +0 -0
@@ -28,6 +28,7 @@ _BAR_XS = {
|
|
28
28
|
"minor_div":None,
|
29
29
|
"minor_frac":0.66,
|
30
30
|
"minor_type":"none",
|
31
|
+
"major_mult":None,
|
31
32
|
"facecolors":["black","white"],
|
32
33
|
"edgecolors":"black",
|
33
34
|
"edgewidth":0.5, # changed
|
@@ -99,6 +100,7 @@ _BAR_SM = {
|
|
99
100
|
"minor_div":None,
|
100
101
|
"minor_frac":0.66,
|
101
102
|
"minor_type":"none",
|
103
|
+
"major_mult":None,
|
102
104
|
"facecolors":["black","white"],
|
103
105
|
"edgecolors":"black",
|
104
106
|
"edgewidth":0.75, # changed
|
@@ -170,6 +172,7 @@ _BAR_MD = {
|
|
170
172
|
"minor_div":None,
|
171
173
|
"minor_frac":0.66,
|
172
174
|
"minor_type":"first",
|
175
|
+
"major_mult":None,
|
173
176
|
"facecolors":["black","white"],
|
174
177
|
"edgecolors":"black",
|
175
178
|
"edgewidth":1, # changed
|
@@ -241,6 +244,7 @@ _BAR_LG = {
|
|
241
244
|
"minor_div":None,
|
242
245
|
"minor_frac":0.66,
|
243
246
|
"minor_type":"first",
|
247
|
+
"major_mult":None,
|
244
248
|
"facecolors":["black","white"],
|
245
249
|
"edgecolors":"black",
|
246
250
|
"edgewidth":2, # changed
|
@@ -312,6 +316,7 @@ _BAR_XL = {
|
|
312
316
|
"minor_div":None,
|
313
317
|
"minor_frac":0.66,
|
314
318
|
"minor_type":"first",
|
319
|
+
"major_mult":None,
|
315
320
|
"facecolors":["black","white"],
|
316
321
|
"edgecolors":"black",
|
317
322
|
"edgewidth":4, # changed
|
@@ -174,8 +174,8 @@ def _validate_or(prop, val, funcs, kwargs):
|
|
174
174
|
# If we pass, we can stop here and return the value
|
175
175
|
success = True
|
176
176
|
break
|
177
|
-
except:
|
178
|
-
|
177
|
+
except Exception as e:
|
178
|
+
continue
|
179
179
|
if success == False:
|
180
180
|
# If we didn't return a value and exit the loop yet, then the passed value is incorrect, as we raise an error
|
181
181
|
raise ValueError(f"{val} is not a valid value for {prop}, please check the documentation")
|
@@ -223,7 +223,7 @@ def _validate_dict(input_dict, default_dict, functions, to_validate=None, return
|
|
223
223
|
# Pre-checking that no invalid keys are passed
|
224
224
|
invalid = [key for key in values.keys() if key not in functions.keys() and key not in ["bbox_to_anchor", "bbox_transform"]]
|
225
225
|
if len(invalid) > 0:
|
226
|
-
|
226
|
+
warnings.warn(f"Warning: Invalid keys detected ({invalid}). These will be ignored.")
|
227
227
|
# First, trimming our values to only those we need to validate
|
228
228
|
if to_validate == "input":
|
229
229
|
values = {key: val for key, val in values.items() if (key in input_dict.keys() and key in functions.keys())} # have to check against both here
|
@@ -241,9 +241,6 @@ def _validate_dict(input_dict, default_dict, functions, to_validate=None, return
|
|
241
241
|
# NOTE: This is messy but the only way to get the rotation value to the crs function
|
242
242
|
if key=="crs":
|
243
243
|
_ = func(prop=key, val=val, rotation_dict=values, **fd["kwargs"])
|
244
|
-
# NOTE: This is messy but the only way to check the projection dict without keywords
|
245
|
-
elif key=="projection":
|
246
|
-
_ = func(prop=key, val=val)
|
247
244
|
# Our custom functions always have this dictionary key in them, so we know what form they take
|
248
245
|
elif "kwargs" in fd:
|
249
246
|
_ = func(prop=key, val=val, **fd["kwargs"])
|
@@ -64,6 +64,7 @@ _VALIDATE_INSET = {
|
|
64
64
|
"pad":{"func":vf._validate_or, "kwargs":{"funcs":[vf._validate_range, vf._validate_and], "kwargs":[{"min":0, "none_ok":True}, {"funcs":[vf._validate_tuple, vf._validate_iterable], "kwargs":[{"length":2, "types":[float, int]}, {"func":vf._validate_range, "kwargs":{"min":0}}]}]}}, # between 0 and inf, or a two-tuple of (x,y) size, each between 0 and inf
|
65
65
|
"coords":{"func":vf._validate_tuple, "kwargs":{"length":2, "types":[float, int], "none_ok":True}}, # a two-tuple of coordinates where you want to place the inset map
|
66
66
|
"to_plot":{"func":vf._validate_iterable, "kwargs":{"func":vf._validate_keys, "kwargs":{"keys":["data","kwargs"], "none_ok":True}}}, # a list of dictionaries, where each contains "data" and "kwargs" keys
|
67
|
+
"zorder":{"func":vf._validate_type, "kwargs":{"match":int}}, # any int
|
67
68
|
}
|
68
69
|
|
69
70
|
_VALIDATE_EXTENT = {
|
@@ -78,6 +79,7 @@ _VALIDATE_EXTENT = {
|
|
78
79
|
"linecolor":{"func":matplotlib.rcsetup.validate_color}, # any color value for matplotlib
|
79
80
|
"alpha":{"func":vf._validate_range, "kwargs":{"min":0}}, # any positive number
|
80
81
|
"linewidth":{"func":vf._validate_range, "kwargs":{"min":0}}, # any positive number
|
82
|
+
"zorder":{"func":vf._validate_type, "kwargs":{"match":int}}, # any int
|
81
83
|
"to_return":{"func":vf._validate_list, "kwargs":{"list":["shape", "patch", "fig", "ax"], "none_ok":True}}, # any value in this list
|
82
84
|
}
|
83
85
|
|
@@ -85,4 +87,5 @@ _VALIDATE_DETAIL = {
|
|
85
87
|
"to_return":{"func":vf._validate_list, "kwargs":{"list":["connectors", "lines"], "none_ok":True}}, # any value in this list
|
86
88
|
"connector_color":{"func":matplotlib.rcsetup.validate_color}, # any color value for matplotlib
|
87
89
|
"connector_width":{"func":vf._validate_range, "kwargs":{"min":0}}, # any positive number
|
90
|
+
"zorder":{"func":vf._validate_type, "kwargs":{"match":int}}, # any int
|
88
91
|
}
|
@@ -96,6 +96,7 @@ class _TYPE_ROTATION(TypedDict, total=False):
|
|
96
96
|
_VALIDATE_PRIMARY = {
|
97
97
|
"location":{"func":vf._validate_list, "kwargs":{"list":["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]}},
|
98
98
|
"scale":{"func":vf._validate_range, "kwargs":{"min":0, "max":None, "none_ok":True}}, # between 0 and inf
|
99
|
+
"zorder":{"func":vf._validate_type, "kwargs":{"match":int}}, # any int
|
99
100
|
}
|
100
101
|
|
101
102
|
_VALIDATE_BASE = {
|
@@ -37,7 +37,7 @@ preferred_divs = {
|
|
37
37
|
7:[2,1],
|
38
38
|
8:[4,2],
|
39
39
|
9:[3,3],
|
40
|
-
10:[
|
40
|
+
10:[2,1],
|
41
41
|
}
|
42
42
|
|
43
43
|
# For converting between units
|
@@ -89,6 +89,7 @@ class _TYPE_BAR(TypedDict, total=False):
|
|
89
89
|
minor_div: int # the number of minor divisions on the bar
|
90
90
|
minor_frac: float # the fraction of the major division that the minor division should be (e.g. 0.5 = half the size of the major division)
|
91
91
|
minor_type: Literal["all","first","none"] # whether the minor divisions should be drawn on all major divisions or just the first one
|
92
|
+
major_mult: float | int # used in conjunction with major_div to define the length of the bar, if desired
|
92
93
|
# Boxes only
|
93
94
|
facecolors: list | tuple | str # a color or list of colors to use for the faces of the boxes
|
94
95
|
edgecolors: list | tuple | str # a color or list of colors to use for the edges of the boxes
|
@@ -165,13 +166,14 @@ class _TYPE_AOB(TypedDict, total=False):
|
|
165
166
|
_VALIDATE_PRIMARY = {
|
166
167
|
"style":{"func":vf._validate_list, "kwargs":{"list":["ticks","boxes"]}},
|
167
168
|
"location":{"func":vf._validate_list, "kwargs":{"list":["upper right", "upper left", "lower left", "lower right", "center left", "center right", "lower center", "upper center", "center"]}},
|
169
|
+
"zorder":{"func":vf._validate_type, "kwargs":{"match":int}}, # only check that it is an int
|
168
170
|
}
|
169
171
|
|
170
172
|
_VALID_BAR_TICK_LOC = get_args(_TYPE_BAR.__annotations__["tick_loc"])
|
171
173
|
_VALID_BAR_MINOR_TYPE = get_args(_TYPE_BAR.__annotations__["minor_type"])
|
172
174
|
|
173
175
|
_VALIDATE_BAR = {
|
174
|
-
"projection":{"func":vf._validate_projection, "kwargs":{"none_ok":False}}, #
|
176
|
+
"projection":{"func":vf._validate_or, "kwargs":{"funcs":[vf._validate_projection, vf._validate_list], "kwargs":[{"none_ok":False}, {"list":["px","pixel","pixels","pt","point","points","dx","custom","axis"], "none_ok":False}]}}, # between 0 and inf, or a two-tuple of (x,y) size, each between 0 and inf
|
175
177
|
"unit":{"func":vf._validate_list, "kwargs":{"list":list(units_standard.keys()), "none_ok":True}}, # any of the listed unit values are accepted
|
176
178
|
"rotation":{"func":vf._validate_range, "kwargs":{"min":-360, "max":360, "none_ok":True}}, # between -360 and 360 degrees
|
177
179
|
"max":{"func":vf._validate_range, "kwargs":{"min":0, "max":None, "none_ok":True}}, # between 0 and inf
|
@@ -179,10 +181,11 @@ _VALIDATE_BAR = {
|
|
179
181
|
"height":{"func":vf._validate_range, "kwargs":{"min":0, "max":None, "none_ok":True}}, # between 0 and inf
|
180
182
|
"reverse":{"func":vf._validate_type, "kwargs":{"match":bool}}, # any bool
|
181
183
|
|
182
|
-
"major_div":{"func":vf._validate_range, "kwargs":{"min":1, "max":None, "none_ok":True}}, # between
|
184
|
+
"major_div":{"func":vf._validate_range, "kwargs":{"min":1, "max":None, "none_ok":True}}, # between 1 and inf
|
183
185
|
"minor_div":{"func":vf._validate_range, "kwargs":{"min":0, "max":None, "none_ok":True}}, # between 0 and inf
|
184
186
|
"minor_frac":{"func":vf._validate_range, "kwargs":{"min":0, "max":1, "none_ok":True}}, # ticks only: between 0 and 1
|
185
187
|
"minor_type":{"func":vf._validate_list, "kwargs":{"list":_VALID_BAR_MINOR_TYPE, "none_ok":True}}, # any item in the list, or None (for no minor)
|
188
|
+
"major_mult":{"func":vf._validate_range, "kwargs":{"min":0, "max":None, "none_ok":True}}, # between 0 and inf
|
186
189
|
|
187
190
|
"facecolors":{"func":vf._validate_iterable, "kwargs":{"func":matplotlib.rcsetup.validate_color}}, # boxes only: any color value for matplotlib
|
188
191
|
"edgecolors":{"func":vf._validate_iterable, "kwargs":{"func":matplotlib.rcsetup.validate_color}}, # boxes only: any color value for matplotlib
|
@@ -202,7 +205,7 @@ _VALID_LABELS_FONTWEIGHT = get_args(_TYPE_LABELS.__annotations__["fontweight"])
|
|
202
205
|
_VALID_LABELS_ROTATION_MODE = get_args(_TYPE_LABELS.__annotations__["rotation_mode"])
|
203
206
|
|
204
207
|
_VALIDATE_LABELS = {
|
205
|
-
"labels":{"func":vf._validate_iterable, "kwargs":{"func":vf._validate_types,"kwargs":{"matches":[str,bool], "none_ok":True}}}, # any list of strings
|
208
|
+
"labels":{"func":vf._validate_iterable, "kwargs":{"func":vf._validate_types,"kwargs":{"matches":[str,bool,int,float], "none_ok":True}}}, # any list of strings
|
206
209
|
"format":{"func":vf._validate_type, "kwargs":{"match":str}}, # only check that it is a string, not that it is a valid format string
|
207
210
|
"format_int":{"func":vf._validate_type, "kwargs":{"match":bool}}, # any bool
|
208
211
|
"style":{"func":vf._validate_list, "kwargs":{"list":_VALID_LABELS_STYLE}}, # any item in the list
|