-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
When exporting a PlotCurveItem to SVG, if the view has undergone a transformation, like say setting log mode, the line will be shifted out of the view and won't be visible after the export is complete.
Cause
I introduced this bug in #2728 In reviewing my diff. In that PR, what I attempted to do was to shift the numerical positioning of the PlotCurveItem to be between -1 and 1, as the underlying issue was one of precision of values that Qt would write to the XML/SVG file. Having Qt not use view coordinates, was the objective here.
I should note, I never liked this fix, having it be conditional on PlotCurveItem seemed hacky, I think we can manipulate the QPainter to use a different world transform such that the coordinates written to the SVG output is between -1 and 1 (we could do a narrower range, but I didn't feel that was necessary).
Reproduction
To reproduce, run this code, right click and export to SVG. The line will shift.
import numpy as np
import scipy
import pyqtgraph as pg
import pyqtgraph.exporters
pg.mkQApp()
### create data
x = np.arange(0,500,10)
y = np.random.random(50)*0.3 + scipy.signal.windows.gaussian(50, std=10)
p1 = pg.plot()
plot_obj = p1.plot(x=x+1000000, y=y, pen='b')
plot_obj.setLogMode(True, False)
p1.show()
if __name__ == "__main__":
pg.exec()If someone sees a way to modify this example such that the user doesn't have to right click, select svg and export explicitly, that would be greatly appreciated.