pg.exporters output files display data cramped into upper left corner

34 views
Skip to first unread message

Fizik Jadershik

unread,
May 28, 2016, 9:35:26 AM5/28/16
to pyqtgraph
Here's minimal working example:

def spectrogram(data):
    import pyqtgraph as pg
    import pyqtgraph.exporters
    from pyqtgraph.Qt import QtCore, QtGui
    app = QtGui.QApplication([])
    plot = pg.ImageView(view=pg.PlotItem())
    plot.setImage(data)
    exporterp = pg.exporters.ImageExporter(plot.imageItem)
    exporterp.export('spectrogramp1.png')
    exporters = pg.exporters.SVGExporter(plot.imageItem)
    exporters.export('spectrograms1.svg')
    plot.close()

if __name__ == "__main__":
    import numpy as np
    test = np.random.randint(-32000, 32000, (2048, 2048))
    spectrogram(test)

What happens is that instead of filling the whole image, the data takes up only a fraction of space in the generated image. For instance, the code for PNG export above reliably produces http://i.imgur.com/8SiV0x0.pnghttp://i.imgur.com/OjF99JD.png ) as the output.

I am not familiar with SVG all that well, but there seems to be a similar problem there too.http://i.imgur.com/AAeBx05.pnghttp://i.imgur.com/3FZESJM.png ). Another thing that I can discern from here, regarding the SVGExporter, is that it seems to be neglecting view=pg.PlotItem() argument for pg.ImageView as I don't see axis there.

Any suggestions? I was able to generate "full size" PNGs initially, but I can't recall any major differences between this code and one of the earlier examples that I wrote.
Reply all
Reply to author
Forward
0 new messages