Matplotlib大量数据

时间:2018-07-01 13:29:33

标签: python matplotlib plot

我想绘制大量数据,但是当我执行matplotlib时,事情会变得很奇怪。

请参阅:

Plotted Recall Figure

看起来数据不是连续的,但是,它在最后附加了两个列表。我读到python列表是有序的,因此绘制它们应该没有问题。 所以我的问题是什么会导致那些奇怪的水平线?

注意:如果我同时绘制较少的值,它将起作用。 (大约25个值可以得到更好的图形,这里只有终点和起点虚假地联系在一起:Plotted Recall Figure with less values

以下是我的代码的简短摘录:

superpix = superpixelNumber
results = recallAVG
plt.ylabel('Recall')
plt.xlabel('Superpixels')
print superpix
print '####'
print results
plt.plot(superpix, results)

superpix = ['964', '1091', '1536', '1629', '1810', '1901', '1964', '2018', '2088', '2349', '2417', '2469', '2654', '2765', '2848', '2892', '2941', '2974', '3064', '3081', '3115', '3119', '3143', '3150', '3155', '3212', '3289', '3318', '3377', '3405', '3407', '3516', '3533', '3547', '3810', '4012', '4013', '4053', '4209', '4285', '4316', '4424', '4431', '4475', '4478', '4499', '4560', '4564', '4619', '4830', '4837', '4849', '4875', '4881', '4975', '4995', '5024', '5071', '5209', '5273', '5288', '5339', '5352', '5371', '5539', '5617', '5792', '5821', '5851', '5859', '5896', '5906', '5971', '5992', '6063', '6137', '6150', '6159', '6168', '6259', '6282', '6324', '6348', '6402', '6501', '6522', '6593', '6647', '6662', '6681', '6824', '6835', '6840', '6869', '6879', '6933', '6949', '7086', '7132', '7156', '7175', '7184', '7211', '7248', '7368', '7472', '7489', '7500', '7511', '7655', '7747', '7779', '7915', '7935', '8050', '8165', '8222', '8262', '8264', '8438', '8443', '8545', '8557', '8644', '8671', '8710', '8779', '8786', '8830', '8851', '8909', '8957', '9008', '9030', '9044', '9045', '9178', '9385', '9466', '9539', '9568', '9580', '9589', '9603', '9730', '10040', '10182', '10285', '10345', '10539', '10542', '10623', '10674', '10736', '10841', '10907', '10928', '10952', '11096', '11140', '11157', '11260', '11316', '11501', '11529', '11568', '11668', '11700', '11749', '11902', '12079', '12236', '12330', '12585', '12804', '13274', '13459', '13602', '13944', '13998', '14157', '14553', '14854', '14857', '15202', '15271', '15930', '16014', '16791', '17242', '18739', '19349', '20145', '21340', '21503', '21848', '22385', '22934', '24635']

####

results = [0.544489, 0.6476833333333333, 0.8120071666666666, 0.6834395, 0.561904625, 0.6241478, 0.5198309999999999, 0.7997744000000001, 0.7927402, 0.38733540000000005, 0.6811011666666666, 0.31748319999999997, 0.6906548, 0.7104231999999999, 0.7904592, 0.6112666, 0.6112056000000001, 0.7106966, 0.6786711666666667, 0.7043264, 0.6531032, 0.7107464, 0.6141873333333333, 0.642922, 0.6281375, 0.6531969999999999, 0.5334163999999999, 0.713445, 0.6838645, 0.55517, 0.5588808000000001, 0.7401632, 0.7575395, 0.49618900000000005, 0.7326644999999999, 0.5333436, 0.7480956, 0.6763588, 0.6479583333333333, 0.6086701666666667, 0.6886296666666666, 0.7927191666666666, 0.7872138000000001, 0.8386618333333334, 0.6493258, 0.6309176000000001, 0.7231950000000001, 0.7305621666666667, 0.5309332, 0.6586155, 0.7128357999999999, 0.7975034000000001, 0.7444255999999999, 0.8303649999999999, 0.5679306, 0.6392124, 0.6555251666666666, 0.6552325999999999, 0.6678068, 0.7479224, 0.46856919999999996, 0.8193335, 0.7291534, 0.7705025, 0.6188564, 0.5745034, 0.8803211666666666, 0.745825, 0.7317174, 0.7680821666666667, 0.7515812, 0.7993342, 0.6954322000000001, 0.7003165, 0.6238643333333334, 0.5572301666666667, 0.7930182, 0.6068512, 0.7714650000000001, 0.7329275000000001, 0.8182447999999999, 0.6985256, 0.7509342000000001, 0.7008111999999999, 0.7911758, 0.7273213999999999, 0.7524605999999999, 0.7907938333333333, 0.7576454, 0.8556896, 0.6714838, 0.6430279999999999, 0.7651656, 0.7390004, 0.7064493333333332, 0.7085924, 0.7695102, 0.8192638333333333, 0.7551354, 0.7028121666666668, 0.875455, 0.7522068333333333, 0.7189924, 0.72603575, 0.6959801666666666, 0.7299698333333334, 0.7037495999999999, 0.7682484, 0.7910786000000001, 0.6468406, 0.7914950000000001, 0.8298270000000002, 0.5833666666666667, 0.6716734000000001, 0.693755, 0.7038998000000001, 0.7118356666666669, 0.6176462, 0.7862823999999999, 0.6589343999999999, 0.641948, 0.6550428, 0.8077074285714285, 0.7217188, 0.8171754, 0.7455430000000001, 0.6760586666666666, 0.8073192, 0.7526198000000001, 0.5985636, 0.5884878, 0.7315267999999999, 0.7921850000000001, 0.7785071666666666, 0.8030158000000001, 0.7808846, 0.8635564, 0.791552, 0.6418918, 0.5921538, 0.5714445, 0.8469682000000001, 0.7457960000000001, 0.6528014, 0.7953612, 0.7482305454545455, 0.6620106000000001, 0.6857932000000001, 0.7869412, 0.8119694999999999, 0.8080288, 0.7167660000000001, 0.7879052, 0.8158552, 0.7944292, 0.6462405999999999, 0.5717346, 0.746576, 0.7192412000000001, 0.6327026, 0.8053162, 0.8435456, 0.45326260000000007, 0.702516, 0.6550973999999999, 0.8167049999999999, 0.858953, 0.7403408, 0.8037054000000001, 0.8554501999999999, 0.7444812857142857, 0.8347054, 0.7900281999999998, 0.6243236, 0.6781092, 0.8021786000000001, 0.7439516000000002, 0.8221598, 0.6984858, 0.8066198333333334, 0.8586328, 0.8275296666666666, 0.7771527500000001, 0.7977257999999999, 0.7837116000000001, 0.8565828333333334, 0.8518712857142857, 0.8727360000000001, 0.7884179999999998, 0.8158571428571427, 0.8863956666666667, 0.7524074, 0.7211422, 0.7527022, 0.8259815999999999, 0.7555484, 0.7844934, 0.7150338, 0.8842191666666667]

1 个答案:

答案 0 :(得分:0)

我无法使用问题中包含的数据来再现剧情中跳跃的问题。话虽如此,请确保您不想绘制相对于整数点的 而不是字符串。在前一种情况下,每个数据点是等距绘制的,并且根据字符串x数据设置标签。您可能要改为在x数据中使用字符串的整数值。

比较:

plt.plot(superpix, results)

original: string x

使用

plt.plot(list(map(int,superpix)), results) # list() is superfluous on python 2

new: plotted vs ints

相关问题