Skip to content

SVG exporter output has errors when data values are very large #2661

@meganbkratz

Description

@meganbkratz

I found a bug when trying to export a plot as an SVG. It seems that incorrect data values are being saved in the .svg when the data values are large (~1,000,000).

Here is a minimal example:

import numpy as np
import scipy


### create data
x = np.arange(0,500,10)
y = np.random.random(50)*0.3 + scipy.signal.gaussian(50, std=10)

### create plot where export works
p1 = pg.plot()
p1.plot(x=x, y=y, pen='g')

### create plot where export doesn't work because we've increased the x-axis values
p2 = pg.plot()
p2.plot(x=x+10000000, y=y, pen='b')

And here is an illustration of the output:
4 plots showing the output of exporting p1 and p2 in the above code as svg and png files. the svg plot of p2 is different than the other 3 - it is more jagged and blocky, as if several different x-values were grouped together.

Here's the pg.systemInfo output for my machine:

sys.version: 3.9.13 (main, Aug 25 2022, 23:26:10) 
[GCC 11.2.0]
qt bindings: PyQt5 5.15.7 Qt 5.15.2
pyqtgraph: 0.13.1; None
config:
{'antialias': False,
 'background': 'k',
 'crashWarning': False,
 'editorCommand': None,
 'enableExperimental': False,
 'exitCleanup': True,
 'foreground': 'd',
 'imageAxisOrder': 'col-major',
 'leftButtonPan': True,
 'mouseRateLimit': 100,
 'segmentedLineMode': 'auto',
 'useCupy': False,
 'useNumba': False,
 'useOpenGL': False}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions