import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
a = pd.DataFrame(np.arange(30).reshape((5, 6)), columns=list('abcdef'),index=['a1','a2','a3','a4','a5'])
n = 1
# n = 2
# axes 没有固定的类型,如果n 只有一位,那么axes就是完全的一个普通的数字
# 如果n>1 且 plt.subplots(n, 1) 中括号里边的数字是1 那么就是一个一维数组,那么引用的时候,就应该ax=ax[i]
# 如果n>1 且 plt.subplots(n, 2) 中括号里边的数字是2 或者是大于2的数字,那么就是一个二维数组,引用的时候,应该ax=ax[1][1] 类型这样
fig1, axes = plt.subplots(n,1,figsize=(15, 10))
print(axes) # AxesSubplot(0.125,0.11;0.775x0.77) # 当 n = 1时
#
# [<matplotlib.axes._subplots.AxesSubplot object at 0x0000000EEB5B13C8>
# <matplotlib.axes._subplots.AxesSubplot object at 0x0000000EEF03A898>
# <matplotlib.axes._subplots.AxesSubplot object at 0x0000000EEF06EE48>
# <matplotlib.axes._subplots.AxesSubplot object at 0x0000000EEF0AB438>
# <matplotl
python matplotlib 中的 axes用法
最新推荐文章于 2023-04-28 09:34:50 发布