生成多个图时奇数Matplotlib错误/警告

时间:2016-05-17 01:24:53

标签: python macos matplotlib

我有两个模拟,每个模拟产生一些我想要绘制的数据。当我添加第二个情节时,我得到的是一些非常奇怪的错误。目前,我的代码如下所示:

Do Some Simulation

kappa_density = stats.kde.gaussian_kde(kappa_estimate)

x = numpy.arange(0,0.0005,0.00001) 
high_density =max(kappa_density(x)) 
fig = plt.figure(figsize=(10,6))
plt.plot(x,kappa_density(x)) 
plt.plot((kappa_central, kappa_central),(0,high_density), 'r--') 
a = plt.Rectangle((0, 0), 0.25, 0.25,fc="red", alpha=1.00) 
b = plt.Rectangle((0, 0), 0.25, 0.25,fc="blue",alpha=1.00) 
plt.legend([a,b], ["Median","Density Estimate"],loc=1,fontsize='small') 
plt.xlabel("Kappa",fontsize=16)
plt.ylabel("Density",fontsize=16)
plt.savefig('KappaEstimateDistribution.pdf')

Do some more simulation

fig2 = plt.figure(figsize=(10,6)) 
plt.hist(tau_estimate,facecolor='green', alpha=0.5)
plt.savefig('TauEstimateDistribution.pdf')

当它运行时,第一个图显示为我显示屏上的黑色未填充框,尽管它已正确保存为文件。第二次模拟完成,正确保存为文件......然后程序崩溃,吐出一系列惊人的警告和错误:

May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const: conn 0x4507f token 0x1ffffffffffe85
May 16 18:22:55  python[58033] <Warning>: Backtrace (at 748802):
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  0   CoreGraphics                        0x00007fff8bd16b98 CGSDisableUpdateToken + 155
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  1   AppKit                              0x00007fff98884524 ___disable_updates_sync_block_invoke_2 + 17
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  2   libdispatch.dylib                   0x00007fff8e69740b _dispatch_client_callout + 8
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  3   libdispatch.dylib                   0x00007fff8e6989f2 _dispatch_barrier_sync_f_invoke + 74
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  4   AppKit                              0x00007fff988843f2 NSCGSDisableUpdates + 213
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  5   AppKit                              0x00007fff98884228 NSCGSTransactionRunPreCommitActionsForOrder_ + 156
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  6   AppKit                              0x00007fff98884179 NSCGSTransactionRunPreCommitActions_ + 31
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  7   AppKit                              0x00007fff988661e3 -[_NSCGSTransaction addActionWithOrder:usingBlock:] + 220
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  8   AppKit                              0x00007fff988660f7 NSCGSTransactionAddAction + 68
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  9   AppKit                              0x00007fff988659f9 NSCGSWindowBackingStoreMark_ + 257
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  10  AppKit                              0x00007fff988658ed -[_NSCGSWindowBackingStore setAttached:] + 57
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  11  AppKit                              0x00007fff9893bd75 _NSCreateWindowWithOpaqueShape2 + 150
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  12  AppKit                              0x00007fff9893a980 -[NSWindow _commonAwake] + 1960
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  13  AppKit                              0x00007fff9893a166 -[NSWindow _makeKeyRegardlessOfVisibility] + 85
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  14  AppKit                              0x00007fff98873429 NSPerformVisuallyAtomicChange + 147
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  15  AppKit                              0x00007fff9893a0af -[NSWindow makeKeyAndOrderFront:] + 79
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  16  _macosx.so                          0x000000010b4ad22d FigureManager_show + 77
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  17  libpython2.7.dylib                  0x00000001000c5385 PyEval_EvalFrameEx + 31621
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  18  libpython2.7.dylib                  0x00000001000c83a3 PyEval_EvalCodeEx + 2131
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  19  libpython2.7.dylib                  0x000000010003e100 function_call + 176
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  20  libpython2.7.dylib                  0x000000010000c552 PyObject_Call + 98
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  21  libpython2.7.dylib                  0x000000010001dbed instancemethod_call + 333
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  22  libpython2.7.dylib                  0x000000010000c552 PyObject_Call + 98
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  23  libpython2.7.dylib                  0x00000001000792d8 slot_tp_init + 88
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  24  libpython2.7.dylib                  0x0000000100076155 type_call + 245
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  25  libpython2.7.dylib                  0x000000010000c552 PyObject_Call + 98
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  26  libpython2.7.dylib                  0x00000001000c0013 PyEval_EvalFrameEx + 10259
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  27  libpython2.7.dylib                  0x00000001000c83a3 PyEval_EvalCodeEx + 2131
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  28  libpython2.7.dylib                  0x00000001000c567d PyEval_EvalFrameEx + 32381
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  29  libpython2.7.dylib                  0x00000001000c83a3 PyEval_EvalCodeEx + 2131
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  30  libpython2.7.dylib                  0x000000010003e100 function_call + 176
May 16 18:22:55  python[58033] <Warning>: void CGSUpdateManager::log() const:  31  libpython2.7.dylib                  0x000000010000c552 PyObject_Call + 98

这是令人恼火的,而不是灾难性的,因为一旦它完成所有事情就会崩溃,但它仍然是一个奇怪的错误。任何人都可以看到我在做什么来触发这个吗?

0 个答案:

没有答案