Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt + Matplotlib
#3
or use the builtin chart in PyQt6

from PyQt6.QtWidgets import QApplication, QMainWindow
import sys
from PyQt6.QtCharts import QChart, QChartView, QLineSeries
from PyQt6.QtCore import QPointF
from PyQt6.QtGui import QPainter
from PyQt6.QtCore import Qt
 
 
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
 
        self.setWindowTitle("PyQtChart Line")
        self.setGeometry(100,100, 680,500)
        self.show()
        self.create_linechart()

    def create_linechart(self): 
        series = QLineSeries(self)
        series << QPointF( 1, 91.9) << QPointF( 2, 89.5) << QPointF( 3, 84.6) << QPointF( 4, 92.0) << QPointF( 5, 87.6) << QPointF( 6, 89.4) << QPointF( 7, 83.9) << QPointF( 8, 90.1) << QPointF( 9, 89.7) << QPointF( 10, 89.6) << QPointF( 11, 86.1) << QPointF( 12, 85.3) << QPointF( 13, 91.3) << QPointF( 14, 89.0) << QPointF( 15, 85.3) << QPointF( 16, 91.6) << QPointF( 17, 91.1) << QPointF( 18, 91.3) << QPointF( 19, 88.3) << QPointF( 20, 84.1) << QPointF( 21, 88.9) << QPointF( 22, 91.1) << QPointF( 23, 86.6) << QPointF( 24, 88.2) << QPointF( 25, 90.3) << QPointF( 26, 89.3) << QPointF( 27, 85.0) << QPointF( 28, 88.6) << QPointF( 29, 86.0) << QPointF( 30, 87.1) << QPointF( 31, 84.3)
 
        chart =  QChart()
 
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.AnimationOption.SeriesAnimations)
        chart.setTitle("Line Chart Example")
 
        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignmentFlag.AlignBottom)
 
        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.RenderHint.Antialiasing)
 
        self.setCentralWidget(chartview)

 
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
Reply


Messages In This Thread
PyQt + Matplotlib - by frohr - Mar-30-2022, 12:59 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Mar-30-2022, 04:26 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Mar-30-2022, 05:44 PM
RE: PyQt + Matplotlib - by frohr - Mar-30-2022, 06:05 PM
RE: PyQt + Matplotlib - by deanhystad - Mar-30-2022, 06:09 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Mar-30-2022, 06:57 PM
RE: PyQt + Matplotlib - by frohr - Mar-30-2022, 08:47 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Mar-30-2022, 09:19 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Mar-31-2022, 01:10 PM
RE: PyQt + Matplotlib - by frohr - Apr-01-2022, 11:39 AM
RE: PyQt + Matplotlib - by Axel_Erfurt - Apr-01-2022, 12:09 PM
RE: PyQt + Matplotlib - by frohr - Apr-02-2022, 06:19 PM
RE: PyQt + Matplotlib - by Axel_Erfurt - Apr-02-2022, 06:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,361 Mar-11-2021, 10:52 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020