Matplotlib提供以下功能:
cla() # Clear axis
clf() # Clear figure
close() # Close a figure window
Run Code Online (Sandbox Code Playgroud)
该文档没有提供很多关于这些功能之间的区别的见解.我什么时候应该使用每个功能,它究竟做了什么?
我正在处理来自许多天线基线的观测数据.目前我正在工作的是绘制~40个数字,每个数字都有4x5子图区域.我发现在使用matplotlib在循环中绘制和保存数字时速度很慢.这是我的代码:
import numpy as np
import matplotlib.pyplot as plt
import time
...
PLT_PAGE_NUM = 39 # default is 39
SUB_PLT_NUM = 20 # default is 20
for pp in xrange(0,PLT_PAGE_NUM):
plt.figure(figsize=(20,12))
start_time = time.clock()
for kk in xrange(0,SUB_PLT_NUM):
plt.subplot(5,4,kk+1)
plt.plot(np.arange(0,TIME_LENGTH), xcor_real_arr[20*pp+kk,0:],'r-',
range(0,TIME_LENGTH), xcor_imag_arr[20*pp+kk,0:],'b-')
plt.title('XCOR of '+ ind_arr[20*pp+kk], color='k')
plt.savefig('test_imag_real'+str(pp)+'.png',format='png',dpi=100)
print 'Fig-'+str(pp)+' has been saved'
print "Excution time:", time.clock()-start_time
Run Code Online (Sandbox Code Playgroud)
执行时间信息是:
######### Check your inputs setting #########
You have selected 2 files.
The time interval is From 2011-10-20_14:28:38 to 2011-10-20_15:10:54
Your time …
Run Code Online (Sandbox Code Playgroud)