matplotlib中创建axes的几种方法

本文介绍了在matplotlib中创建axes的六种方法:Figure.add_subplot、Figure.add_axes、pyplot.subplot、pyplot.axes、Figure.subplots以及pyplot.subplots。详细讲解了每种方法的用法,并提供了相关API链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大概有这么几种吧

.Figure.add_subplot
.Figure.add_axes
.pyplot.subplot
.pyplot.axes
.Figure.subplots
.pyplot.subplots

1 .Figure.add_subplot

https://matplotlib.org/stable/api/figure_api.html?highlight=figure%20add_subplot#matplotlib.figure.Figure.add_subplot

fig = plt.figure()

fig.add_subplot(231)
ax1 = fig.add_subplot(2, 3, 1)  # equivalent but more general

fig.add_subplot(232, frameon=False)  # subplot with no frame
fig.add_subplot(233, projection='polar')  # polar subplot
fig.add_subplot(234, sharex=ax1)  # subplot sharing x-axis with ax1
fig.add_subplot(235, facecolor="red")  # red subplot

ax1.remove()  # delete ax1 from the figure
fig.add_subplot(ax1)  # add ax1 back to the figure

2 .Figure.add_axes

https://matplotlib.org/stable/api/figure_api.html?highlight=figure%20add_subplot#matplotlib.figure.Figure.add_axes

rect = l, b, w, h
fig = plt.figure()
fig.add_axes(rect)
fig.add_axes(rect, frameon=False, facecolor='g')
fig.add_axes(rect, polar=True)
ax = fig.add_axes(rect, projection='polar'</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值