Data Science · मराठी आवृत्ती
19.2 matplotlib reference
x, y आणि values आधी तयार करा. Bar, line आणि hist या वेगवेगळ्या chart examples आहेत; गरजेनुसार एक निवडा.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8, 4))
ax.bar(x, y)
ax.plot(x, y, marker="o")
ax.hist(values, bins=10)
ax.set_title("..."); ax.set_xlabel("..."); ax.set_ylabel("...")
plt.xticks(rotation=30, ha="right")
fig.tight_layout()
fig.savefig("figures/chart.png", dpi=120)
plt.show()
figures folder तयार असावा. Labels मध्ये अर्थपूर्ण नावं आणि units भरा; “...” तसंच ठेवू नका.