Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Update BarPlot in continuazione
Forum Updated to NodeBB v4.3 + New Features

Update BarPlot in continuazione

Scheduled Pinned Locked Moved Unsolved Italian
1 Posts 1 Posters 315 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TommasoFurieri
    wrote on last edited by
    #1

    Ciao a tutti. Sono nuovo del forum e sto imparando ad usare Qt for Python (Pyside2).

    Fino ad adesso sono sempre riuscito a cavarmela cercando online e sulla documentazione ufficiale.
    Purtroppo però adesso ho incontrato un'ostacolo che a me sembrava banale rispetto a tutto quello che ho fatto finora, ma che non riesco a superare.

    Al momento ho un QTimer() che si aggiorna 20 volte al secondo.
    Ogni volta che "scatta" il timer, vengono eseguite diverse operazioni, tra cui la necessità di plottare un grafico a barre che si deve continuamente aggiornare in base al valore assunto da self.z_coeff che è una lista.

    A quanto pare plottare dei grafici a barre non è così immediato (almeno non lo è stato per me) con Pyside2.

    Ho disegnato l'interfaccia con Qt Designer e ho destinato un QWidget al grafico (object name: zernike_bar_plot).

    Quando l'interfaccia si avvia, lancio una funzione che ha questo al suo interno:

    def set_zernike_plot(self):
    
        self.zernike_barset = QtCharts.QBarSet('zernike_bp')
        self.zernike_barset.append(self.z_coeff.tolist())
        self.zernike_barset.setColor(QColor(0, 230, 0))
    
        self.zernike_series = QtCharts.QBarSeries()
        self.zernike_series.append(self.zernike_barset)
        self.zernike_series.setBarWidth(1)
    
        self.zernike_plot_chart = QtCharts.QChart()
        self.zernike_plot_chart.addSeries(self.zernike_series) 
    
        self.zernike_plot_chart.createDefaultAxes()
        self.zernike_plot_chart.legend().hide()
    
        self.zernike_plot_chart.axisX(self.zernike_series).setVisible(False)
        self.zernike_plot_chart.axisY(self.zernike_series).setVisible(False)
    
        self.zernike_chartview = QtCharts.QChartView(self.zernike_plot_chart)
    
        self.ui.zernike_bar_plot.setContentsMargins(0, 0, 0, 0)
        self.zernike_layout = QHBoxLayout(self.ui.zernike_bar_plot)
    
        self.zernike_layout.setContentsMargins(0, 0, 0, 0)
        self.zernike_layout.addWidget(self.zernike_chartview)
    

    E qua già il primo problema. Non sono riuscito in nessun modo a dirgli di plottare con l'asse y limitato tra [-1,1].

    Quello poi che vorrei fare è lanciare una funzione dal timeout del timer che mi aggiorni il plot con i nuovi valori di self.z_coeff. Tuttavia non riesco ad aggiornare semplicemente il plot, ma devo richiamare tale funzione ogni volta.

    Vi ringrazio infinitamente in anticipo!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved