Matplotlib
Creates static, animated, and interactive visualizations.
- Downloads / mo
- 196.4M
- Stars
- 23.5K
- Last release
- 3.11.2
- License
- Matplotlib
Strengths
- Creates static and interactive figures. Use the same plotting library for image files and interactive windows.
- Exports publication image formats. Save figures as PNG, PDF, or SVG.
Limitations
- Interactivity needs an appropriate backend. Choose an interactive backend for live windows instead of image-only output.
Quickstart
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.show()
Matplotlib examples
def _histplot_mpl_op(values, values2, rotated, ax, hist_kwargs, is_circular): """Add a histogram for the data to the axes.""" bins = hist_kwargs.pop("bins", None) if is_circular == "degrees": if bins is None: bins = get_bins(values) values = np.deg2rad(values) bins = np.deg2rad(bins) elif is_circular: labels = [ "0", f"{np.pi/4:.2f}", f"{np.pi/2:.2f}", f"{3*np.pi/4:.2f}", f"{np.pi:.2f}", f"{-3*np.pi/4:.2f}", f"{-np.pi/2:.2f}", f"{-np.pi/4:.2f}", ] ax.set_xticklabels(labels) if values2 is not None: raise NotImplementedError("Insert hexbin plot here") if bins is None: bins = get_bins(values) if values.dtype.kind == "i": hist_kwargs.setdefault("align", "left") else: hist_kwargs.setdefault("align", "mid") n, bins, _ = ax.hist(np.asarray(values).flatten(), bins=bins, **hist_kwargs) if values.dtype.kind == "i": ticks = bins[:-1] else: ticks = (bins[1:] + bins[:-1]) / 2 if rotated: ax.set_yticks(ticks) elif not is_circular: ax.set_xticks(ticks) if is_circular: ax.set_ylim(0, 1.5 * n.max()) ax.set_yticklabels([]) if hist_kwargs.get("label") is not None: ax.legend() return ax