Matplotlib binding to PyQt5 (No menu)

Source: Internet
Author: User

Very simple implementation of matplotlib binding to PYQT5

"Knowledge points"

1 Import matplotlib 2 matplotlib.use ("qt5agg")34from  Import  Figurecanvasqtagg as Figurecanvas5fromimport Figure

【】

"Source Code"

1 ImportNumPy as NP2 ImportMatplotlib3Matplotlib.use ("Qt5agg")4 5  fromMatplotlib.backends.backend_qt5aggImportFigurecanvasqtagg as Figurecanvas6  fromMatplotlib.figureImport Figure7 8  fromPyQt5Importqtwidgets9 Ten  One classWidget (Figurecanvas): A     def __init__(Self, Parent=none, width=5, height=4, dpi=100): -Fig = figure (figsize= (width, height), dpi=100) -Figurecanvas.__init__(self, fig) the self.setparent (parent) -          -         #Scatter Chart -Self.axes = Fig.add_subplot (211) +Self.axes.scatter (Np.random.rand), Np.random.rand (20)) -          +         #Line Chart ASelf.axes2 = Fig.add_subplot (212) atx = Np.arange (0, 5, 0.1) - self.axes2.plot (x, Np.sin (x), X, Np.cos (x)) -  -Self.setwindowtitle ("Example: Matplotlib binding to PyQt5") -  - if __name__=="__main__": in     ImportSYS -App =qtwidgets.qapplication (SYS.ARGV) toW =widgets () + w.show () -Sys.exit (App.exec_ ())

Matplotlib binding to PyQt5 (No menu)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.