add some mathematical functions ; mostly from the math lessons themselfs
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from typing import List
|
||||
|
||||
def r_boxplot(arr: List[float], label: str) -> None:
|
||||
data = np.asarray(arr, dtype=float)
|
||||
p = np.percentile(data, [0, 25, 50, 75, 100])
|
||||
|
||||
fig, ax = plt.subplots(figsize=(6, 2.5))
|
||||
ax.boxplot(data, positions=[1], vert=False, patch_artist=True, widths=0.6)
|
||||
|
||||
labels = ["0%", "25%", "50%", "75%", "100%"]
|
||||
for val, lab in zip(p, labels):
|
||||
ax.axvline(val, color="#ff0000", linestyle="--", linewidth=0.8, alpha=0.9)
|
||||
|
||||
ax.text(0.5, 1.15, label, transform=ax.transAxes,
|
||||
ha="center", va="bottom", fontsize=10, fontweight="bold", color="black")
|
||||
|
||||
ax.set_yticks([1])
|
||||
ax.xaxis.grid(True, linestyle="--", alpha=0.3)
|
||||
|
||||
fig.tight_layout()
|
||||
fig.subplots_adjust(top=0.78)
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user