新手必学matplotlib

Getting started

Installation quick-start

Install using pip:

pip install matplotlib

Install using conda:

conda install matplotlib

Further details are available in the Installation Guide.

Draw a first plot

Here is a minimal example plot:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()

(Source code, png, pdf)

../../_images/index-1.png

If a plot does not show up please check Troubleshooting.

Where to go next

  • Check out Plot types to get an overview of the types of plots you can create with Matplotlib.

  • Learn Matplotlib from the ground up in the Quick-start guide.

posted @ 2022-04-14 14:41  来瓶冰可乐  阅读(32)  评论(2编辑  收藏  举报