I recently switched from MATLAB to Python for data analysis and I am using matplotlib for visualization of the data. This works fine if the number of data points I would like to visualise are low. However, if I would like to visualize e.g.
import matplotlib.pyplot as plt
signal = [round(random.random() * 100) for i in xrange(0, 1000000)]
plt.plot(signal)
plt.show()
I am getting an error:
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in __call__
    return self.func(*args)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 276, in resize
    self.show()
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 348, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 451, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1034, in draw
    func(*args)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 2086, in draw
    a.draw(renderer)
  File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/lines.py", line 562, in draw
    drawFunc(renderer, gc, tpath, affine.frozen())
  File "/usr/lib/pymodules/python2.7/matplotlib/lines.py", line 938, in _draw_lines
    self._lineFunc(renderer, gc, path, trans)
  File "/usr/lib/pymodules/python2.7/matplotlib/lines.py", line 978, in _draw_solid
    renderer.draw_path(gc, path, trans)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 145, in draw_path
    self._renderer.draw_path(gc, path, transform, rgbFace)
OverflowError: Allocated too many blocks
Can you give me an advise what you would do in this case? Are you down sampling your data? If I perform the same plot in MATLAB even with more data points, I haven't had this problem before.
Not sure exactly what you are trying to show but you can change the plot to '.' and it will work.
import random
import pylab as plt
signal = [round(random.random() * 100) for i in xrange(0, 1000000)]
plt.plot(signal, '.')
plt.show()
You may be able to get what you want by customising using the matlotlibrc file, the docs are here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With