你什么时候应该使用斧头.在matplotlib中? [英] When should you use ax. in matplotlib?
本文介绍了你什么时候应该使用斧头.在matplotlib中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我仍然不了解无花果的最佳用法,请.和斧头.在matplotlib中我应该使用 plt.每时每刻?什么时候应该斧头.用吗?
I still don't understand the best usage of fig, plt. and ax. in matplotlib Should I be using plt. all the time? When should ax. be used?
推荐答案
Use fig
and ax
are part of the object oriented interface and should be used as often as possible.
在大多数情况下,使用旧的 plt
界面也可以使用,但是当您创建和操纵许多图形或轴时,跟踪所有图形可能会变得非常棘手:
Using the old plt
interface works in most cases too, but when you create and manipulate many figures or axes it can become quite tricky to keep track of all your figures:
plt.figure()
plt.plot(...) # this implicitly modifies the axis created beforehand
plt.xlim([0, 10]) # this implicitly modifies the axis created beforehand
plt.show()
相比
fig, ax = plt.subplots(1, 1)
ax.plot(...) # this explicitly modifies the axis created beforehand
ax.set_xlim([0, 10]) # this explicitly modifies the axis created beforehand
plt.show()
这篇关于你什么时候应该使用斧头.在matplotlib中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文