matplotlib中axes和axis的区别


原文链接 https://www.zhihu.com/question/51745620

# figure  画板

# axes  轴域,包括轴的集合和一些其他特征,画纸

# subplot()  vs.  add_axes()

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax3 = fig.add_axes([0.1,0.1,0.8,0.8])
ax4 = fig.add_axes([0.71,0.71,0.4,0.4])
plt.show()

 

 

 # axes方法和pyplot函数

 

 

 

 两种方法都可以实现一样的结果,这也代表是贯穿python变成的两种思路:函数式编程和对象式编程,我们这里可以比较一下两套工具的优缺点:

axis顾名思义就是轴。

axes简单说来就是灵活的子图。和Subplot的关系见官网上axes的说明:

Most of you are probably familiar with the Subplot, which is just a special case of an Axes that lives on a regular rows by columns grid of Subplot instances. If you want to create an Axes at an arbitrary location, simply use the add_axes() method which takes a list of [left, bottom, width, height] values in 0-1 relative figure coordinates:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM