python pyqtgraph 儲存圖片到本地

來源:互聯網
上載者:User

標籤:檔案   class   nump   rap   def   支援   可視化   尾碼   port   

pyqtgraph官方給的樣本居然會報錯2333

官方文檔傳送門:#####pyqtgraph export

pyqtgraph支援在可視化視窗中右鍵儲存(Exporting from the GUI)試了一下只能儲存為svg格式,

儲存為png會閃退不知道是我這裡的原因還是這裡有bug,我希望直接產生圖片(Exporting from the API)

先查看本地site-packages裡面有test檔案,裡面有產生svg的版本畫出來的圖是svg格式只能放在瀏覽器看不能改尾碼名

而我希望產生png之類的圖片

折騰了一下終於弄了一個能跑的出來:

from __future__ import division, print_function, absolute_importimport pyqtgraph as pgimport pyqtgraph.exportersimport numpy as npdef test_plotscene():    pg.setConfigOption(‘foreground‘, (255,255,255))    w = pg.GraphicsWindow()    p = w.addPlot()    p.plot(np.linspace(0.0, 20.0, 20), pen={‘color‘:‘w‘})    p.setXRange(0,20)    p.setYRange(-10,20)    app = pg.mkQApp()    app.processEvents()    ex = pyqtgraph.exporters.ImageExporter(w.scene())    ex.export(fileName="test.png")if __name__ == "__main__":    test_plotscene()

 

 

python pyqtgraph 儲存圖片到本地

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.