Skip to content

Matplotlib 速查表

1735199341620

Matplotlib

python

# $ pip3 install matplotlib
import matplotlib.pyplot as plt

plt.plot/bar/scatter(x_data, y_data [, label=<str>])  # Also plt.plot(y_data).
plt.legend()                                          # Adds a legend.
plt.title/xlabel/ylabel(<str>)                        # Adds a title or label.
plt.savefig(<path>)                                   # Saves the plot.
plt.show()                                            # Displays the plot.
plt.clf()                                             # Clears the plot.