多处理和Matplotlib Legend有时文本不正确

时间:2018-08-02 20:24:50

标签: python matplotlib python-multiprocessing

所以我正在做的是使用多处理(略)加快对matplot lib图像的绘图。在大多数情况下,我拥有的代码都可以正常工作,但不是100%。

这是我的一些绘图代码:

import matplotlib.pyplot as plot

def plot(index):
    fig = plot.figure(figsize=(6.5875*2, 6.2125*2))
    temperature = patches.Patch(color='red', label="Temperature")
    dewpoint = patches.Patch(color='green', label="Dewpoint")
    parcel = patches.Patch(color='black', label="Parcel")
    self.plot.legend(handles=[temperature,dewpoint],loc=2, fontsize=14)
    fig.savefig(filename, bbox_inches = 'tight')

from multiprocessing import Pool
import multiprocessing
past_files = [0,1,2,3,4]
try:
    pool = Pool(5)
    pool.map(plot,range(len(past_files)))
except:
    pool.close()
    pool.terminate()
    pool.join()
finally:
    pool.close()
    pool.terminate()
    pool.join()

错误的情况:

enter image description here

很好的情况:

enter image description here

0 个答案:

没有答案