簡體   English   中英

Matplotlib:繪制偏移曲線,每個曲線都有相應的y軸

[英]Matplotlib: plot offset curves, each with corresponding y-axis

我是第一次接觸Matplotlib的新手。 我想在同一個圖中繪制一些(四個)不同的數據集,我需要抵消它們,否則它們會重疊。

這是我需要獲得的: http//s4.postimg.org/skaclr06l/example.jpg

現在,將一個常量添加到不同的數據集以抵消它們會很簡單,但我需要每個繪圖都有一個從0開始的相應縱坐標軸,如我發布的示例所示。 我在matplotlib網站上找到了一個非常接近它的解決方案:

# Three subplots sharing both x/y axes
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing both axes')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)

問題在於,通過這種方式,我獲得了單獨的圖,而我希望它們部分重疊,例如,通常使用吸收光譜(參見此處的示例http://nte-serveur.univ-lyon1)。 fr / spectroscopie / raman / Image42.gif

你可以幫幫我嗎?

你試圖分別繪制每條曲線,最后使用一個plt.show()嗎?

這將在同一圖上繪制曲線,但您必須為y值提供偏移。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM