导入库
import numpy as np
import matplotlib.pyplot as plt
plt.scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, *, data=None, **kwargs)
plt.scatter(x, y)
plt.hist(x, bins=None, range=None, density=None, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, normed=None, *, data=None, **kwargs)
# 将x作频率统计,分5个区间
plt.hist(x, bins=5)
plt.bar(x, y, width,color, edgecolor, bottom, linewidth, align, tick_label, align)
plt.bar(x, y)
plt.plot(x, y, format_string, **kwargs)
plt.plot(x, y)
plt.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None)
plt.boxplot(x)
箱型图得到的数据
fill_between填充两条水平曲线之间的区域。
fill_betweenx填充两条垂直曲线之间的区域。
plt.fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, *, data=None, **kwargs)
x:横坐标
y1,y2:两条曲线的y坐标
plt.fill_between(x, 0, y, y>0, color='blue', alpha=.25)
plt.fill_between(x, 0, y, y<0, color='red', alpha=.25)
plt.show()
plt.matshow(mat, cmap=plt.cm.Blues)
def f(x, y):
return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)
n = 10
x = np.linspace(-3, 3, 4 * n)
y = np.linspace(-3, 3, 3 * n)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
plt.matshow(Z, cmap='hot', origin='lower')
plt.colorbar()