mgplot 0.2.28__py3-none-any.whl → 0.2.29__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.
- mgplot/finalise_plot.py +36 -3
- {mgplot-0.2.28.dist-info → mgplot-0.2.29.dist-info}/METADATA +1 -1
- {mgplot-0.2.28.dist-info → mgplot-0.2.29.dist-info}/RECORD +5 -5
- {mgplot-0.2.28.dist-info → mgplot-0.2.29.dist-info}/WHEEL +0 -0
- {mgplot-0.2.28.dist-info → mgplot-0.2.29.dist-info}/licenses/LICENSE +0 -0
mgplot/finalise_plot.py
CHANGED
|
@@ -38,9 +38,9 @@ class FinaliseKwargs(BaseKwargs):
|
|
|
38
38
|
title: NotRequired[str | None]
|
|
39
39
|
xlabel: NotRequired[str | None]
|
|
40
40
|
ylabel: NotRequired[str | None]
|
|
41
|
-
xlim: NotRequired[tuple[float, float] | None]
|
|
41
|
+
xlim: NotRequired[tuple[float | int | Period, float | int | Period] | None]
|
|
42
42
|
ylim: NotRequired[tuple[float, float] | None]
|
|
43
|
-
xticks: NotRequired[list[float] | None]
|
|
43
|
+
xticks: NotRequired[list[float | int | Period] | None]
|
|
44
44
|
yticks: NotRequired[list[float] | None]
|
|
45
45
|
xscale: NotRequired[str | None]
|
|
46
46
|
yscale: NotRequired[str | None]
|
|
@@ -179,7 +179,7 @@ def apply_value_kwargs(axes: Axes, value_kwargs_: Sequence[str], **kwargs: Unpac
|
|
|
179
179
|
|
|
180
180
|
# --- loop over potential value settings
|
|
181
181
|
for setting in value_kwargs_:
|
|
182
|
-
value = kwargs.get(setting)
|
|
182
|
+
value = _convert_period_value(axes, setting, kwargs.get(setting))
|
|
183
183
|
if setting in kwargs:
|
|
184
184
|
# deliberately set, so we will action
|
|
185
185
|
axes.set(**{setting: value})
|
|
@@ -238,6 +238,39 @@ def _convert_period_coords(axes: Axes, method_name: str, item: dict[str, Any]) -
|
|
|
238
238
|
return converted
|
|
239
239
|
|
|
240
240
|
|
|
241
|
+
# Value-kwargs whose entries are x-axis coordinates — like axvline/axvspan, a
|
|
242
|
+
# Period passed here must be converted to its ordinal on a period-mapped axes.
|
|
243
|
+
_PERIOD_X_VALUE_KWARGS: Final[tuple[str, ...]] = ("xlim", "xticks")
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _convert_period_value(axes: Axes, setting: str, value: Any) -> Any:
|
|
247
|
+
"""Return value with any Period x-coordinates replaced by ordinals.
|
|
248
|
+
|
|
249
|
+
xlim is a 2-tuple and xticks a list; either may contain Periods when the
|
|
250
|
+
caller describes the axis in calendar terms. On a period-mapped axes the
|
|
251
|
+
Period freq must match the axes' stashed freq (see register_period_axes).
|
|
252
|
+
Non-x settings, None, and non-Period entries pass through unchanged.
|
|
253
|
+
"""
|
|
254
|
+
if setting not in _PERIOD_X_VALUE_KWARGS or not isinstance(value, (tuple, list)):
|
|
255
|
+
return value
|
|
256
|
+
stash = get_period_axes(axes)
|
|
257
|
+
stashed_freq = stash[0] if stash is not None else None
|
|
258
|
+
converted: list[Any] = []
|
|
259
|
+
for val in value:
|
|
260
|
+
if isinstance(val, Period):
|
|
261
|
+
if stashed_freq is not None and val.freqstr != stashed_freq:
|
|
262
|
+
raise ValueError(
|
|
263
|
+
f"{setting} Period freq {val.freqstr!r} does not match axes freq {stashed_freq!r}",
|
|
264
|
+
)
|
|
265
|
+
if stashed_freq is not None:
|
|
266
|
+
# Widen the stash so the later label refresh covers this coordinate.
|
|
267
|
+
register_period_axes(axes, PeriodIndex([val]))
|
|
268
|
+
converted.append(val.ordinal)
|
|
269
|
+
else:
|
|
270
|
+
converted.append(val)
|
|
271
|
+
return tuple(converted) if isinstance(value, tuple) else converted
|
|
272
|
+
|
|
273
|
+
|
|
241
274
|
def _apply_splat(axes: Axes, method_name: str, value: _SplatValue) -> None:
|
|
242
275
|
"""Apply a single splat kwarg, which may be a dict or sequence of dicts."""
|
|
243
276
|
if value is None or value is False:
|
|
@@ -4,7 +4,7 @@ mgplot/axis_utils.py,sha256=-wnjUTL2MdwEntLEVihDABOxLSbux0aSyATCnIsVumg,16041
|
|
|
4
4
|
mgplot/bar_plot.py,sha256=FobAsadYSEf-U0RZFgZutTzse4Rgr0TDFyWUMM68JVs,12513
|
|
5
5
|
mgplot/colors.py,sha256=f5q4z7kORUu66uAxNeK9KAZ64gv_7h_x2qH53BvzwPw,4848
|
|
6
6
|
mgplot/fill_between_plot.py,sha256=XJvtkBeOkohHyayQnu84jURapB5RsMAR-3SaskHkHfM,3361
|
|
7
|
-
mgplot/finalise_plot.py,sha256=
|
|
7
|
+
mgplot/finalise_plot.py,sha256=fLl9GOreS7L53vGeVEEJBfI2l8NVjBbGj4xty1So0Ao,17450
|
|
8
8
|
mgplot/finalisers.py,sha256=Wozq4XOmnMdhEB9LJqHao9TrleOfhNV54kRa_bgN-e8,10547
|
|
9
9
|
mgplot/growth_plot.py,sha256=QALNYyINd_u7BL3q-My16eRuhq0LzGfawu-_MsVOXl0,8708
|
|
10
10
|
mgplot/keyword_checking.py,sha256=8CFexwEK_Uyv3_8hAnJ2ewk0tEjNjkwzKfX2uFw2UpM,11446
|
|
@@ -19,7 +19,7 @@ mgplot/seastrend_plot.py,sha256=hi9t0cY0bHdIOU5abLMX7qvAp_hlVLlJFyEKNBzg6Ts,2000
|
|
|
19
19
|
mgplot/settings.py,sha256=RhxgX4d-CgRpvs-ALG_j8tg3wwHSyfvFNdL0aMjofA0,5584
|
|
20
20
|
mgplot/summary_plot.py,sha256=Kg7VD8KFIls4KlD4jeaaXnDw51BZ3p_wMAUpjG49zGQ,11102
|
|
21
21
|
mgplot/utilities.py,sha256=PfzThb_nXYIMhnprQzNcaBqUZV8ysHJte0TU7TIis00,8450
|
|
22
|
-
mgplot-0.2.
|
|
23
|
-
mgplot-0.2.
|
|
24
|
-
mgplot-0.2.
|
|
25
|
-
mgplot-0.2.
|
|
22
|
+
mgplot-0.2.29.dist-info/METADATA,sha256=wdTklpbAVuStMDb5NUXrLQfhzWaEEp39R6k6c0hVrJs,7923
|
|
23
|
+
mgplot-0.2.29.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
24
|
+
mgplot-0.2.29.dist-info/licenses/LICENSE,sha256=6ZyruOwF8J7mY25-vZHdOibtY8cSNLz0vWeH59TLhtw,1082
|
|
25
|
+
mgplot-0.2.29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|