Search code examples
matplotlibpypy

Is there any 2D plotting library compatible with pypy?


I am a heavy user of jupyter notebook and, lately, I am running it using pypy instead of python to get extra speed. It works perfectly but I am missing matplotlib so much. Is there any decent 2D plotting library compatible with pypy and jupyter notebook? I don't need fancy stuff, scatter, line and bar plots would be more than enough.


Solution

  • Bokeh is working fairly good with pypy. The only problem I have encountered is linked to the use of numpy.datetime64 that is not yet supported by pypy. Fortunately it is enough to monkey-patch bokeh/core/properties.py and bokeh/util/serialization.py to pass in case of datetime64 reference.

    I did it in this way:

    bokeh/core/properties.py

    ...
            try:
                import numpy as np
                datetime_types += (np.datetime64,)
            except:
                pass
    ...
    

    and

    bokeh/util/serialization.py

    ...
        # Check for astype failures (putative Numpy < 1.7)
        try:
            dt2001 = np.datetime64('2001')
            legacy_datetime64 = (dt2001.astype('int64') ==
                            dt2001.astype('datetime64[ms]').astype('int64'))
        except:
            legacy_datetime64 = False
            pass
    ...
    

    And managed to get nice looking plots in jupyter using pypy.