简介:本文将详细介绍Python Matplotlib库中plt.figure()、plt.subplot() 、plt.subplots() 、plt.xticks() 、plt.xlim()和 plt.grid()六个函数的使用方法和应用场景。
一、plt.figure()函数
plt.figure()函数用于创建一个新的图形窗口,或者返回一个已存在的图形窗口。它的常用参数有:
二、plt.subplot()函数
import matplotlib.pyplot as pltplt.figure(figsize=(6,4), dpi=80, facecolor='w', edgecolor='k', frameon=True)
三、plt.subplots()函数
import matplotlib.pyplot as pltfig = plt.figure()ax1 = plt.subplot(2, 2, 1)
四、plt.xticks()函数
import matplotlib.pyplot as pltfig, axes = plt.subplots(2, 2)
五、plt.xlim()函数
import matplotlib.pyplot as pltplt.xticks([1, 2, 3], ['a', 'b', 'c'])
import matplotlib.pyplot as pltplt.xlim(0, 4)