matplot同時畫兩條線,程式碼範例

來源:互聯網
上載者:User

效果圖:

代碼:


import matplotlib.pyplot as pltmigtime = [16.6,16.5,16.9,17.1,17.2,18.1,18.2,18.4,19.4,19.3,20.4,20.3,22,21.7,22]delay = [108,98,92,83,87,77,85,48,31,58,35,43,36,31,19]fig,ax = plt.subplots()plt.xlabel('migration speed (MB/s)')plt.ylabel('migration time (s); request delay (ms)')"""set interval for y label"""yticks = range(10,110,10)ax.set_yticks(yticks)"""set min and max value for axes"""ax.set_ylim([10,110])ax.set_xlim([58,42])x = [57,56,55,54,53,52,51,50,49,48,47,46,45,44,43]plt.plot(x,migtime,"x-",label="migration time")plt.plot(x,delay,"+-",label="request delay")"""open the grid"""plt.grid(True)plt.legend(bbox_to_anchor=(1.0, 1), loc=1, borderaxespad=0.)plt.show()



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.