onekit 2.1.1__tar.gz → 2.2.1__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.
- {onekit-2.1.1 → onekit-2.2.1}/PKG-INFO +1 -1
- {onekit-2.1.1 → onekit-2.2.1}/pyproject.toml +1 -1
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/vizkit.py +69 -0
- {onekit-2.1.1 → onekit-2.2.1}/LICENSE +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/README.md +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/__init__.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/dekit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/mathkit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/numpykit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/optfunckit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/pandaskit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/pythonkit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/sklearnkit.py +0 -0
- {onekit-2.1.1 → onekit-2.2.1}/src/onekit/sparkkit.py +0 -0
|
@@ -13,6 +13,9 @@ from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
|
13
13
|
from mpl_toolkits.mplot3d.axes3d import Axes3D
|
|
14
14
|
|
|
15
15
|
from onekit import numpykit as npk
|
|
16
|
+
from onekit import pythonkit as pk
|
|
17
|
+
|
|
18
|
+
ArrayLike = npt.ArrayLike
|
|
16
19
|
|
|
17
20
|
__all__ = (
|
|
18
21
|
"Config",
|
|
@@ -21,6 +24,7 @@ __all__ = (
|
|
|
21
24
|
"create_xyz_points",
|
|
22
25
|
"discrete_cmap",
|
|
23
26
|
"plot_contour",
|
|
27
|
+
"plot_digitscale",
|
|
24
28
|
"plot_line",
|
|
25
29
|
"plot_surface",
|
|
26
30
|
"plot_xy_points",
|
|
@@ -481,6 +485,71 @@ def plot_contour(
|
|
|
481
485
|
return ax
|
|
482
486
|
|
|
483
487
|
|
|
488
|
+
def plot_digitscale(
|
|
489
|
+
x: ArrayLike,
|
|
490
|
+
y: ArrayLike | None = None,
|
|
491
|
+
cmap_name: str = "YlOrBr_r",
|
|
492
|
+
kws_plot: dict[str, str] | None = None,
|
|
493
|
+
ax=None,
|
|
494
|
+
) -> Axes:
|
|
495
|
+
"""Plot a digit-scaled version of :math:`y` against :math:`x`.
|
|
496
|
+
|
|
497
|
+
See Also
|
|
498
|
+
--------
|
|
499
|
+
onekit.mathkit.digitscale : Python version
|
|
500
|
+
|
|
501
|
+
Examples
|
|
502
|
+
--------
|
|
503
|
+
>>> from onekit import mathkit as mk
|
|
504
|
+
>>> from onekit import vizkit as vk
|
|
505
|
+
>>> vk.plot_digitscale(tuple(mk.collatz(27))) # doctest: +SKIP
|
|
506
|
+
"""
|
|
507
|
+
ax = ax or plt.gca()
|
|
508
|
+
|
|
509
|
+
kwargs_plot = dict(marker=".", color="black")
|
|
510
|
+
kwargs_plot.update(kws_plot or dict())
|
|
511
|
+
for k in ["x", "y"]:
|
|
512
|
+
kwargs_plot.pop(k, None)
|
|
513
|
+
|
|
514
|
+
if y is None:
|
|
515
|
+
y = x
|
|
516
|
+
x = np.arange(len(y))
|
|
517
|
+
|
|
518
|
+
y_values = np.asarray(y)
|
|
519
|
+
y_scaled = npk.digitscale(y_values)
|
|
520
|
+
ax.plot(x, y_scaled, **kwargs_plot)
|
|
521
|
+
x_limits = ax.get_xlim()
|
|
522
|
+
|
|
523
|
+
y_min = int(np.floor(y_scaled.min()))
|
|
524
|
+
y_max = int(np.ceil(y_scaled.max()))
|
|
525
|
+
y_range = tuple(range(y_min, y_max))
|
|
526
|
+
colors = discrete_cmap(y_max, name=cmap_name, lower_bound=0.2, upper_bound=0.8)
|
|
527
|
+
|
|
528
|
+
for i, yi in enumerate(y_range):
|
|
529
|
+
ax.fill_between(x_limits, yi, yi + 1, color=colors[i], alpha=0.3)
|
|
530
|
+
|
|
531
|
+
ax.set_xlim(x_limits)
|
|
532
|
+
ax.set_yticks(y_range)
|
|
533
|
+
|
|
534
|
+
ax.set_xlabel("index")
|
|
535
|
+
ax.set_ylabel("num_digits(orig_value)", labelpad=6)
|
|
536
|
+
|
|
537
|
+
ax.set_title(
|
|
538
|
+
pk.concat_strings(
|
|
539
|
+
", ",
|
|
540
|
+
f"mean={pk.num_to_str(y_values.mean())}",
|
|
541
|
+
f"median={pk.num_to_str(float(np.median(y_values)))}",
|
|
542
|
+
f"std={pk.num_to_str(y_values.std(ddof=1))}",
|
|
543
|
+
f"min={pk.num_to_str(y_values.min())}",
|
|
544
|
+
f"max={pk.num_to_str(y_values.max())}",
|
|
545
|
+
),
|
|
546
|
+
size="medium",
|
|
547
|
+
pad=12,
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
return ax
|
|
551
|
+
|
|
552
|
+
|
|
484
553
|
def plot_line(xy_pts: XyPoints, /, *, kws_plot=None, ax=None) -> Axes:
|
|
485
554
|
"""Plot :math:`y` versus :math:`x` as line.
|
|
486
555
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|