matplotlib - 文本很慢的savefig

时间:2015-05-04 21:41:45

标签: python performance matplotlib plot matplotlib-basemap

我只是想知道matplotlib.pyplot.savefig()的性能。这是一张简单的地图。只有国家边界需要大约1秒钟。 当我在地图上用text()打印只有21x19值的网格时,它需要3秒!为什么会这样?有工作吗?

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import pickle
import numpy as np
import time

plt.clf()
m = pickle.load(open('a.pickle','rb'))
c = pickle.load(open('b.pickle','rb'))

x, y = m(lons, lats) # compute map proj coordinates

for i in range(322,343,1):       # lons
    for j in range(97,116,1):    # lats
        plt.text(x[j,i], y[j,i], int(round(data[j,i])),fontsize=7, color='k', ha='center', va='center')

print time.clock()-t1
plt.savefig('/var/www/img/test.png', bbox_inches='tight',pad_inches=0.05, dpi=100)
print time.clock()-t1
plt.close('all')

0 个答案:

没有答案