Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: DPI keeps doubling when creating a new MatPlotLib QtWidget in qt6 #26380

Open
@hydroEng

Description

@hydroEng

Bug summary

I ran into this bizarre bug, I am not sure if it's a skill issue on my end, but I am trying to embed a plot in my qt6 application. Allowing the user to plot and replot for some reason keeps increasing the sizes of my chart elements, butonly when I have display scaling on (e.g. 125%, 150% etc). To illustrate:

wat

See below for the code, basically I am creating a new plot every time there is a mouse click on that row. Embeddingprint(self.chart.figure.dpi) shows that my plot's dpi keeps doubling every other time I trigger a click. Console output:

100.0100.0200.0200.0400.0400.0

I can workaround this by explicitly setting the figure DPI, e.g. figure.dpi = 100 when creating it. But I assume that means I'm giving up display scaling

Code for reproduction

importmatplotlibmatplotlib.use("Qt5Agg")frommatplotlib.backends.backend_qt5aggimportFigureCanvasQTAggfrommatplotlib.figureimportFigurefromPyQt6.QtWidgetsimport (QWidget,QVBoxLayout,QFrame)classGraphView(QWidget):def__init__(self):super().__init__()self.layout=QVBoxLayout()self.separator=Noneself.chart=MplCanvas()self.figures=Noneself.init_widget()definit_widget(self):self.init_separator()self.layout.addWidget(self.separator)self.layout.addWidget(self.chart)self.setLayout(self.layout)    ...# Note this is the code that triggers when I click a row.defupdate_graph(self,figure):self.chart.deleteLater()self.chart=MplCanvas(fig=figure)self.layout.addWidget(self.chart)self.layout.update()classMplCanvas(FigureCanvasQTAgg):def__init__(self,fig=Figure()):super(MplCanvas,self).__init__(fig)

Actual outcome

Figure DPI keeps dynamically doubling

Expected outcome

DPI shouldn't double like that, it's madness☹️

Additional information

No response

Operating system

Windows, Linux

Matplotlib Version

3.6.3

Matplotlib Backend

QtAgg

Python version

3.11.4

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp