1

I try to plot time series with Plotly. Graphs typically contain 200 000 rows and 10 curves resulting in a 80Mo html files. But this 200 000 rows is limited by the MemoryError raised by Plotly, and this is very limiting my studies.

    py.plot(fig, filename=self.filename, auto_open=True)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\site-packages\plotly\offline\offline.py", line 586, in plot
    pio.write_html(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\site-packages\plotly\io\_html.py", line 508, in write_html
    html_str = to_html(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\site-packages\plotly\io\_html.py", line 137, in to_html
    jdata = json.dumps(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 234, in dumps
    return cls(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\site-packages\_plotly_utils\utils.py", line 60, in encode
    return _json.dumps(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 234, in dumps
    return cls(
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38-32\lib\json\encoder.py", line 202, in encode
    return ''.join(chunks)
MemoryError

I already implemented downsizing (like this topic suggests), and also rounding values to a limited number of decimals to avoid having to big .html files. But still it is not enough.

Also, for example when plotting 10 curves, even if they share the same X axis, the html file will contain 10 times the same X vector. Is there a way to improve that?

When I look at the memory while Plotly is concatenating data and when it stops working, it seems to be utilizing only 500Mo of RAM while my computer memory is far from being full, with still 1 or 2 Go of RAM free. Thus I don't understand why this MemoryError is raised. Is there a dedicated memory space parameter somewhere in Plotly or Python options?

I am even ready to use any other library that would allow me to draw large graphs as long as they provide sufficient interactivity. For example Matplotlib is able to draw large time series when Plotly cannot, but it is way less interactive. This one seems super light and dedicated to time series, but I did not find any Python package of it and it would require to develop the Python interface from scratch.

Maxime
  • 594
  • 5
  • 17
  • I found a first solution [here](https://stackoverflow.com/a/59101232/6693076), not related to Plotly : I was running on 32bits version which was limiting the amount of RAM that can be used. Installing the 64bits version of Python, it's way better! – Maxime May 29 '20 at 18:28

1 Answers1

1

https://bcolz.readthedocs.io/en/latest/intro.html#bcolz-at-glance

I did some quick searching on Google based on your issue and this seems like a reasonable solution, although I'm not sure you will be able to utilize it with Plotly. You'll have to give it a shot on your own.

Sean Payne
  • 1,625
  • 1
  • 8
  • 20
  • I am not sure I am gonna go this way since I am working with Pandas rather than Numpy, but this package seems to have great potential. I did not know it, thanks! – Maxime May 29 '20 at 18:31