matplotlib 高级画图--填充--建立子图

 

1, 填充

这个教学网址不错

fill正常就画出来曲线了,然后填充了正常将于x轴围成的区域填充。

plt.vlines(Sim_T, [0], 1, color="green", linewidth=3, linestyles="dashed")
    ax.fill_betweenx(p, Sim_T, s, facecolor="orange", color="white")
 

2,建立子图--设置坐标轴属性----这个代码相当值得学习了。

fig.tight_layout(); 这条语句最好加上,每一个子图后面都要加上

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 5 * np.pi, 1000)
y1 = np.sin(x)
fig = plt.figure(figsize=(15, 8), dpi=80)
axs = fig.subplots(3, 3, sharex=True, sharey=True)

'''图一'''
axs[0,0].fill(x, y1, color="g", alpha=0.3) # 正常情况下
fig.tight_layout(); # 当子图存在时候,这条语句最好加上
'''图二'''
axs[0,1].fill(x, y1, color="g", alpha=0.3)
axs[0,1].spines['right'].set_visible(False) # 第二张图的效果,容易理解
fig.tight_layout();
'''图三'''
axs[0,2].fill(x, y1, color="g", alpha=0.3) # 三,
axs[0,2].spines['bottom'].set_position(('data',0)) # 这个语句将坐标轴移到了中间了。 0 代表:将横轴移动到了y = 0的位置。
axs[0,2].spines['left'].set_position(('data',0)) # 将纵轴移动到x=0的位置
fig.tight_layout();
'''图四'''
axs[1,0].fill(x, y1, color="g", alpha=0.3)
axs[1,0].spines['top'].set_color('none') # 第四张图的效果,容易理解
fig.tight_layout();

'''图五'''
axs[1,1].fill(x, y1, color="g", alpha=0.3)
axs[1,1].xaxis.set_ticks_position('top') # 第五张图的效果,tick变到上面了。
axs[1,1].yaxis.set_ticks_position('right')
fig.tight_layout();
'''图六'''
axs[1,2].fill(x, y1, color="g", alpha=0.3)
axs[1,2].spines['left'].set_position(('data',0)) # 将纵轴移动到0的位置
fig.tight_layout();
'''图七'''
axs[2,0].set_title('picture 7  title ')
axs[2,0].annotate('zhu  shi ', xy=(0, 0))
fig.tight_layout();
plt.show()

柱状图:

https://www.cnblogs.com/linyujin/p/9895328.html

不同的子图画不同的图像,比如1图画散点图,二图画柱状图subplot2grid

函数subplot2grid()的使用方法

http://book.51cto.com/art/201809/584017.htm

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值