matplotlib 64位栏空白

时间:2017-11-20 09:24:43

标签: python matplotlib

我正在使用Python.org在Windows 10上正式发布的最新版本的64位Python。

>>> sys.version
'2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)]'

有两个数据向量sp1sp2,并将其归一化为最高值,最高值为100.我想在同一图中使用bar进行比较{{1 }}。但是,保存的图形为白色(或空白),如下所示。 enter image description here 我用于baring的代码是:

matplotlib

代码最初以Python 32位运行,并且运行良好。由于我必须处理大量数据,我转向Python 64位,然后出现这个import matplotlib.pyplot as plt from math import floor, ceil sp1 = [[110.0709, 45.0], [113.105, 89.0], [114.1093, 236.0], [115.1071, 70.0], [116.1098, 332.036], [117.1118, 135.0], [118.1093, 276.0], [119.1148, 88.0], [120.0791, 49.0], [121.1197, 437.0], [136.0767, 34.1259], [139.0833, 36.0004], [141.0944, 58.036], [143.0981, 83.7717], [145.1055, 53.0], [147.1081, 42.0], [149.1147, 45.0], [158.0878, 49.0], [161.1083, 29.0], [175.1172, 188.5742]] sp2 = [[101.0693, 51.0], [102.055, 35.0], [110.0711, 43.0], [112.0854, 47.0], [113.1062, 186.0], [114.1097, 501.0], [115.1083, 168.0], [116.1096, 829.0], [117.1132, 258.0], [118.1094, 614.0], [119.1123, 190.0], [120.1185, 36.0], [121.1199, 1049.0], [136.0735, 292.0], [139.0847, 107.0], [141.0918, 128.0], [143.1005, 232.0], [145.1077, 123.0], [147.1073, 112.0], [149.1159, 86.0]] # x and y values of vector sp1 mz1, int1 = [x[0] for x in sp1], [x[1] for x in sp1] # normalize the vector to the highest value with highest value being 100. int1 = [x/max(int1)*100. for x in int1] # x and y values of vector sp2 mz2, int2 = [x[0] for x in sp2], [x[1] for x in sp2] # normalize the vector to the highest value with highest value being 100. int2 = [x/max(int2)*-100. for x in int2] # bar vectors fig, ax = plt.subplots() specbar1 = ax.bar(mz1, int1, width = 0.001) specbar2 = ax.bar(mz2, int2, width = 0.001, color = 'r', edgecolor = 'r') # plot baseline at y=0 xlim = ax.get_xlim() xl = [x/10. for x in xrange(int(floor(xlim[0]))*10, int(ceil(xlim[1]))*10)] yl = [0]*len(xl) ax.plot(xl, yl, color = 'k') # save figure plt.savefig('test.png') plt.close() 问题。但是,bar有效,如上所示。我怎么能想到这个?

0 个答案:

没有答案