Bug with exporter on Ubuntu 16 and python 2.7

419 views
Skip to first unread message

François

unread,
Feb 9, 2017, 5:40:00 AM2/9/17
to pyqtgraph
Dear all,

I recently updated pyqtgraph from 0.9 to 0.10 and now have a problem with the exporter.

The same bug appears in the example code given in the documentation:
http://www.pyqtgraph.org/documentation/exporting.html

This is what I get:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyqtgraph as pg
>>> import pyqtgraph.exporters
>>> plt = pg.plot([1,5,2,4,3])
>>> exporter = pg.exporters.ImageExporter(plt.plotItem)
>>> exporter.parameters()['width'] = 100
>>> exporter.export('fileName.png')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/exporters/ImageExporter.py", line 70, in export
    bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)
TypeError: 'float' object cannot be interpreted as an index

Best
François

vas...@gmail.com

unread,
Feb 9, 2017, 11:33:28 PM2/9/17
to pyqt...@googlegroups.com
quick fix:
change ImageExporter.py:

bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)
to:
bg = np.empty((int(self.params['width']), int(self.params['height']), 4), dtype=np.ubyte)

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/f8558f05-4cad-4438-9ce6-fa51b5f3c973%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

François Posseik

unread,
Feb 10, 2017, 3:18:31 AM2/10/17
to pyqt...@googlegroups.com
It works! Thanks.

François

On 02/10/2017 05:33 AM, vas...@gmail.com wrote:
> quick fix:
> change *ImageExporter.py*:
> *bg = np.empty((self.params['width'], self.params['height'], 4),
> dtype=np.ubyte)*
> to:
> *bg = np.empty((int(self.params['width']), int(self.params['height']),
> 4), dtype=np.ubyte)*
> send an email to pyqtgraph+...@googlegroups.com
> <mailto:pyqtgraph+...@googlegroups.com>.
> <https://groups.google.com/d/msgid/pyqtgraph/f8558f05-4cad-4438-9ce6-fa51b5f3c973%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> 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+...@googlegroups.com
> <mailto:pyqtgraph+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyqtgraph/CAD_qyJoUO8C8ur%2BaPDMXBrmnJ7VCTbQ-zpA5ZSE8xk6VM4rX3A%40mail.gmail.com
> <https://groups.google.com/d/msgid/pyqtgraph/CAD_qyJoUO8C8ur%2BaPDMXBrmnJ7VCTbQ-zpA5ZSE8xk6VM4rX3A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages