2016-05-05 45 views
0

說我想在matplotlib中創建一個圖形。我想要多個地塊,其中一些值遠離其他地塊。即:如何顯示matplotlib中y值有很大差異的多個圖表?

import matplotlib.pyplot as plt 
plt.plot([0, 1, 2, 3, 4], [6.4, 6.7, 6.3, 7.5, 6.6]) 
plt.plot([0, 1, 2, 3, 4], [57.8, 61.7, 57.8, 57.5, 60.5]) 
plt.plot([0, 1, 2, 3, 4], [54.8, 53.3, 55.0, 55.2, 54.9]) 
plt.plot([0, 1, 2, 3, 4], [5400.0, 5362.9, 5333.9, 5206.4, 5333.1]) 
plt.plot([0, 1, 2, 3, 4], [538167.4, 506828.5, 506889.6, 507461.0, 509221.0]) 
plt.plot([0, 1, 2, 3, 4], [51024218.8, 51006151.4, 50929451.5, 51382173.5, 51204708.1]) 
plt.savefig('help.png') 

這是對應於上述線路圖:

Matplotlib figure

但是你會發現,你甚至不能看到大部分的地塊(你也許可以發現2- 3個圖)總共有6個。有沒有辦法讓這些線出現而沒有聚集起來,這樣你就可以看到每一行?

+1

要看你的需求,你可以使用雙y軸或對數刻度 – tom

回答

1

我的建議是把在y軸的數軸,如:

import matplotlib.pyplot as plt 
plt.plot([0, 1, 2, 3, 4], [6.4, 6.7, 6.3, 7.5, 6.6]) 
plt.plot([0, 1, 2, 3, 4], [57.8, 61.7, 57.8, 57.5, 60.5]) 
plt.plot([0, 1, 2, 3, 4], [54.8, 53.3, 55.0, 55.2, 54.9]) 
plt.plot([0, 1, 2, 3, 4], [5400.0, 5362.9, 5333.9, 5206.4, 5333.1]) 
plt.plot([0, 1, 2, 3, 4], [538167.4, 506828.5, 506889.6, 507461.0, 509221.0]) 
plt.plot([0, 1, 2, 3, 4], [51024218.8, 51006151.4, 50929451.5, 51382173.5, 51204708.1]) 
plt.yscale('log') 
plt.savefig('help.png') 

結果: a busy cat

+0

謝謝,這似乎是最好的方式來做到這一點。 – cenh

相關問題