[Python] I need to render a Plotter object on QWidget

Discussão em 'Python' iniciado por Stack, Abril 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to render a Plotter object created by Seaborn.object.Bar() on Qwidget from PyQt6.

    plot = (
    so.Plot(result, x = 'XXX', y = 'XXX')
    .add(so.Bar(color='lightblue'))
    .label(title = "XXX", x = 'XXX', y = 'XXX')
    )


    I used to render plots by passing Axes object generated by Figure.add_subplot() to Seaborn.barplot() method as a kwarg and then converting them into QWidget objects by using FigureCanvasQTAgg class from matplotlib.backends.backend_qtagg

    fig = Figure()
    ax = fig.add_subplot(111)
    ...
    sns.barplot(..., ax = ax)
    ...
    self.main_layout.addWidget(FigureCanvasQTAgg(fig))


    But since FigureCanvasQTAgg only take a Figure object as an argument, I am pretty stuck here.

    Continue reading...

Compartilhe esta Página