随笔 - 119  文章 - 0  评论 - 5  阅读 - 57360

plt绘制子图

plt绘制子图

plt.subplot(221)
# equivalent but more general
# 子图1
ax1 = plt.subplot(2, 2, 1)
# add a subplot with no frame
# 子图2
ax2 = plt.subplot(222, frameon=False)
# add a polar subplot
# 子图3
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
# 子图4
plt.subplot(224, sharex=ax1, facecolor='red')

删除一个子图。

plt.subplot(221)
# equivalent but more general
ax1 = plt.subplot(2, 2, 1)
# add a subplot with no frame
ax2 = plt.subplot(222, frameon=False)
# add a polar subplot
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
plt.subplot(224, sharex=ax1, facecolor='red')
# delete ax2 from the figure
plt.delaxes(ax2)

image-20211102151041377

x = [1,2,3]
y1 = x
y2 = [4,5,6]
y3 = [7,8,9]
y4 = [12,9,11]
ax1 = plt.subplot(221)
ax1.margins(0.05)
ax1.plot(x,y1)
# 标题
ax1.set_title('1',loc='left')
ax2 = plt.subplot(222)
ax2.margins(0.05)
ax2.plot(x,y2)
# 标题
ax2.set_title('2')
ax3 = plt.subplot(223)
ax3.margins(0.05)
ax3.plot(x,y3)
# 标题
ax3.set_title('3')
ax4 = plt.subplot(224)
ax4.margins(0.05)
ax4.plot(x,y3)
# 标题
ax4.set_title('4')

image-20211102151136377

posted on   cookie的笔记簿  阅读(2856)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示