matplotlib画廊--各种图形绘图代码

要常看使用matplotlib可制作的各种图表,请访问http://matplotlib.org/的示例画廊。单击画廊中的图表, 就可查看用于生成图表的代码。

下边将能够绘画的图表列出,你可以点击网页进入网页查看具体代码。

Line Plot
Multiple subplots in one figure

                                                  Images

                           Contouring and pseudocolor

                                           Histograms

                                                  Bar charts

                           Three-dimensional plotting

                                               Ellipses


还有更过图的样式,可以上网站参考http://matplotlib.org/


下边是使用网站代码绘制的图:

                                               网页上的图

                               使用代码会话的图

上图绘图代码:


import numpy as np
import matplotlib.pyplot as plt


x1 = np.linspace(0.0, 5.0)
x2 = np.linspace(0.0, 2.0)

y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2)

plt.subplot(2, 1, 1)
plt.plot(x1, y1, 'o-')
plt.title('A tale of 2 subplots')
plt.ylabel('Damped oscillation')

plt.subplot(2, 1, 2)
plt.plot(x2, y2, '.-')
plt.xlabel('time (s)')
plt.ylabel('Undamped')

plt.show()

猜你喜欢

转载自blog.csdn.net/Sophia_11/article/details/84753622