您的位置:首页 > 编程语言 > Python开发

python matplotlib绘图

2015-07-08 12:49 771 查看
matplotlib: clearing a plot, when to use cla(), clf() or close()?

Matplotlib offers three functions:cla() # Clear axis clf() # Clear figure close() # Close a figure windowThe documentation doesn't offer a lot of insight into what the difference between these functions is. When should I use each function and what exactly does it do?

They all do different things, since matplotlib uses a hierarchical order in which a figure window contains a figure which may consist of many axes. The three commands you mention therefore do the following:cla() clears an axis, i.e. the currently active axis in the current figure. It leaves the other axes untouched.clf() clears the entire current figure with all its axes, but leaves the window opened, such that it may be reused for other plots.close() closes a window, which will be the current window, if not specified otherwise.Which functions suits you best depends thus on your use-case.The close() function furthermore allows one to specify which window should be closed. The argument can either be a number or name given to a window when it was created using figure(number_or_name) or it can be a figure instance fig obtained, i.e., usingfig = figure(). If no argument is given to close(), the currently active window will be closed. Furthermore, there is the syntax close('all'), which closes all figures.
http://www.ibm.com/developerworks/cn/linux/l-matplotlib/index.html 这里也有不少可以学习的东西
http://www.w3school.com.cn/xmldom/dom_element.asp
其实无论什么语言,xml的结构和函数就这些,下次就不用绕了。唉,以前用java时,也是老跑这里找,python又到这里,下次就记住点啊,长点记性。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: