I am experiencing a similar issue. I noticed when exporting from the 
context menu everything works correctly, however, when I export 
programmatically the scatterplot datapoints are all shifted to the right. 
Is there a way to use the same mechanism programmatically that the context 
menu uses?

On Friday, November 21, 2014 at 12:17:53 AM UTC-6, Peter Maunz wrote:
>
> 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
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/6eff7d6e-0ebf-4c67-b850-5864f73ec0a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to