python - 将 AxesSubplots 的 pyplot 数组耦合到图形对象
问题描述
我有一个 pandas DataFrame,我正在使用 df.plot 函数来制作一个子图面板。
像这样的东西:
x = np.random.randn(50)
df = pd.DataFrame({'1': x, '2': x, '3': x, '4':x})
ax_lst = df.plot(subplots = True, layout = (2,2))
df.plot 函数返回一个 AxesSubplots 的 numpy 数组。如何将它与图形对象耦合,以便更改图形级属性?
我已经尝试过,但没有奏效:
fig = plt.figure()
fig.axes.append(ax_lst)
解决方案
每个Axes
对象都有一个get_figure
方法。在你的情况下,
fig = ax_lst[0].get_figure()
推荐阅读
- kdb - KDB - 似乎无法将 csv 文件导入表
- javascript - 每次调用的多个 ajax 调用都会更新变量
- html - 应用 tbody 时的区别 td:nth-of-type(3){ border-bottom-color: transparent; } 和 tr.noborder td{ 边框底部:透明;} 在 CSS 中
- php - PDO lastInsertid() 返回 false,即使我的查询运行良好。给出 0000 代码错误
- ballerina - 如何在 Ballerina 中迭代字符串?
- javascript - 按属性值查找对象属性的索引
- python - 如何在 pyspark 数据框中创建序列号列?
- android - 如何在 ConstraintLayout 中居中一对视图?
- jq - 尝试从 json 中提取数据时 jq 挂起
- cloudflare-apps - 我可以使用 Cloudflare Apps 创建 SRV 记录吗?