pxMode=True ignores QPainterPath symbol shape?

60 views
Skip to first unread message

Israel Brewster

unread,
Apr 7, 2022, 5:46:09 PM4/7/22
to pyqtgraph
I’m not sure if this is a bug or something I am not understanding/doing wrong, but it seems that if I specify the symbol for a plot as a QPainterPath, when plotted with pxMode = True the shape/content of the QPainterPath is ignored and the plot is created using squares. With pxMode=False, the plot is drawn correctly. Am I just missing something?

Example code:

from PySide2.QtGui import QPainterPath
from PySide2.QtWidgets import QApplication, QDialog, QVBoxLayout, QLabel
import pyqtgraph as pg

if __name__ == "__main__":
    print(pg.__version__)
    app = QApplication()
    dialog = QDialog()
    dialog.setWindowTitle("Zoom tests")

    layout = QVBoxLayout(dialog)

    circle_path = QPainterPath()
    circle_path.addEllipse(-1, -1, 2, 2)

    xvals = list(range(10))
    yvals = list(range(10))

    # Grid on right axis, zoom point significantly offset
    plotWidget = pg.PlotWidget(dialog)
    plotWidget.plot(xvals, yvals,
                    symbol = circle_path,
                    symbolBrush = "#F00",
                    symbolPen = None,
                    pen = None,
                    symbolSize = .5,
                    pxMode = False)

    plotWidget2 = pg.PlotWidget(dialog)
    plotWidget2.plot(xvals, yvals,
                     symbol = circle_path,
                     symbolBrush = "#F00",
                     symbolPen = None,
                     pen = None,
                     symbolSize = 50,
                     pxMode = True)

    layout.addWidget(QLabel("Pixel Mode On"))
    layout.addWidget(plotWidget)

    layout.addWidget(QLabel("Pixel Mode Off"))
    layout.addWidget(plotWidget2)

    dialog.show()

    app.exec_()

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320

Israel Brewster

unread,
Apr 13, 2022, 5:21:48 PM4/13/22
to pyqtgraph
Any thoughts on the below issue? I’m running into a situation where I need to do custom symbols with pxMode=True so they don’t resize when zooming. As always, I’m happy to dig deeper into the PyQtGraph source, but it would be nice to know where to look :-) Thanks.

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320

Israel Brewster

unread,
Apr 13, 2022, 5:38:17 PM4/13/22
to pyqtgraph
My apologies, please ignore the previous messages with this subject - turns out this was just me being an idiot. The documentation CLEARLY states that the QPainterPath needs to be “centered at 0,0” and with a width and height of 1. The entire problem was how I was specifying the QPainterPath. Sorry for the noise!

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
On Apr 7, 2022, at 1:46 PM, Israel Brewster <ijbre...@alaska.edu> wrote:

Reply all
Reply to author
Forward
0 new messages