Matplotlib中plot和scatter以及subplot和add_axes区别

之前在做练习时一直有两种方法。plot和scatter一直傻傻分不清,加上这次对matplotlib深入了解,可以清楚的去做判断。
plot用法

from matplotlib import pyplot as plt
plt.plot([5,6,7,8],[7,3,8,3])
plt.show()

这里写图片描述

scatter用法

from matplotlib import pyplot as plt
plt.scatter([5,6,7,8],[7,3,8,3])
plt.show()

这里写图片描述
这样清楚可见了,plot画点以后会用一条线串起来,而scatter只是单独的点而已。
具体的参数还要详见官网了,样式呀,颜色呀。等等。
还有一个容易混的就是 subplot和axes 这有一个小总结,我觉的挺好哇
参考:https://www.cnblogs.com/xiaopengli/p/8058408.html
subplot()方法很好理解,前两个数字代表生成几行几列的子图矩阵,最后一个数字代表选中的子图位置。
这里写图片描述
add_axes()方法通过相对位置增加子图
这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/ll_master/article/details/81704166
今日推荐