Misaligned points and lines when saving a plot?

68 views
Skip to first unread message

Charles Mooney

unread,
Mar 11, 2015, 5:05:10 PM3/11/15
to pyqt...@googlegroups.com
Hello,

I am currently using PyQtPlot as part of a project I'm working on that needs to plot touchpad data onto the screen.  Essentially it records the events being emitted by a touchpad and then draws points at each place the finger was reported and connects them with lines.  The library is working great, and is fast enough to do this mostly live, but when the gesture is done my, program saves a .png of the resulting plot to disk.

The problem I'm running into is that the saved .png's don't look like the live view.  In the saved .png images the dots as scaled wrong and offset from the lines.  The lines actually look just fine, the only problem is the dots are out of place.  I'm not sure if this is something I'm doing wrong or if it's a bug.  Has anyone run into this problem as well?

I've attached a screenshot of the live-view where everything is normal (screenshot.png) as well as one of the saved plots that corresponds with the screenshot showing the misplaced symbols (plot.png).
The source code that generated this can be found in our open-source repo here: https://chromium.googlesource.com/chromiumos/platform/touch_firmware_test/+/master/plotter.py

The salient points of how the code works is that the lines are drawn using setData()
  1. plot.setData(x=xs, y=ys, pen=self.pens_by_tid[tid], symbol='o', symbolSize=ps, symbolPen=self.pens_by_tid[tid], symbolBrush=None)
And the image is saved using ImageExporter
  1. exporter = pg.exporters.ImageExporter(self.plot_window.plotItem)
  2. exporter.parameters()['width'] = TouchPlotter.EXPORT_IMAGE_WIDTH
  3. exporter.export(tmp_filename)

Thanks for any help on this
-Charlie
plot.png
screenshot.png

Luke Campagnola

unread,
Mar 11, 2015, 8:53:37 PM3/11/15
to pyqt...@googlegroups.com
This looks like one of the long-standing bugs:  https://github.com/pyqtgraph/pyqtgraph/issues/16
Is that right?


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/c4d03705-cc5b-4686-8693-3fd50d27783b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luke Campagnola

unread,
Mar 13, 2015, 11:03:49 PM3/13/15
to pyqt...@googlegroups.com
As a workaround until this is fixed, I would try exporting to SVG instead and then using inkscape to render to whatever resolution you prefer. 

Charles Mooney

unread,
Mar 17, 2015, 12:35:56 PM3/17/15
to pyqt...@googlegroups.com
Thanks for the tip!  That does look like the same bug, I'll try going to SVG first and see if that takes care of it.

Thanks,
Charlie
Reply all
Reply to author
Forward
0 new messages