Hi Luke,
I am seeing the following bug or issue:
I am selecting export to png from the context menu and I have a line plot together with points.
When I leave the width in points at the default given in the gui, everything works fine.
However, when I choose a different width in points (for example for a better quality print), then the points do not appear at the right position, or the points are outside the plot region and are omitted altogether.
I am running pyqtgraph develop 7fa0ce9711bee1a0edb8d0f8a3a615afce90d599 from 11/14/2014 on windows using WinPython-64bit-2.7.6.4
I poked around in the source code and found a way to kind of fix it. I don't claim that is a good way to fix it, I just hope that will make debugging for you easier.
![]()
Changes:
diff --git a/pyqtgraph/exporters/ImageExporter.py b/pyqtgraph/exporters/ImageExporter.py
index 78d9310..16922c8 100644
--- a/pyqtgraph/exporters/ImageExporter.py
+++ b/pyqtgraph/exporters/ImageExporter.py
@@ -77,7 +77,7 @@ class ImageExporter(Exporter):
## set resolution of image:
origTargetRect = self.getTargetRect()
- resolutionScale = targetRect.width() / origTargetRect.width()
+ resolutionScale = targetRect.width() / float(origTargetRect.width()) # need float division here
#self.png.setDotsPerMeterX(self.png.dotsPerMeterX() * resolutionScale)
#self.png.setDotsPerMeterY(self.png.dotsPerMeterY() * resolutionScale)
diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py
index b125cb7..d6ff608 100644
--- a/pyqtgraph/graphicsItems/AxisItem.py
+++ b/pyqtgraph/graphicsItems/AxisItem.py
@@ -811,6 +811,8 @@ class AxisItem(GraphicsWidget):
if None in points:
return
lengthInPixels = Point(points[1] - points[0]).length()
+ if self._exportOpts and 'resolutionScale' in self._exportOpts:
+ lengthInPixels /= self._exportOpts['resolutionScale']
if lengthInPixels == 0:
return
diff --git a/pyqtgraph/graphicsItems/GraphicsItem.py b/pyqtgraph/graphicsItems/GraphicsItem.py
index 2ca3519..b7fc6e0 100644
--- a/pyqtgraph/graphicsItems/GraphicsItem.py
+++ b/pyqtgraph/graphicsItems/GraphicsItem.py
@@ -102,7 +102,8 @@ class GraphicsItem(object):
Extends deviceTransform to automatically determine the viewportTransform.
"""
if self._exportOpts is not False and 'painter' in self._exportOpts: ## currently exporting; device transform may be different.
- return self._exportOpts['painter'].deviceTransform() * self.sceneTransform()
+ scaling = QtGui.QTransform.fromScale( self._exportOpts['resolutionScale'], self._exportOpts['resolutionScale']) if 'resolutionScale' in self._exportOpts else QtGui.QTransform.fromScale( 1,1)
+ return self._exportOpts['painter'].deviceTransform() * self.sceneTransform() * scaling
if viewportTransform is None:
view = self.getViewWidget()
With this changes exporting the whole scene works. However, when exporting less than the whole scene, the points are still off.
![]()
Thanks very much,
--Peter