yhat / ggpy

ggplot port for python
http://yhat.github.io/ggpy/
BSD 2-Clause "Simplified" License
3.7k stars 572 forks source link

TypeError at function save_as_base64() #593

Open thippo opened 7 years ago

thippo commented 7 years ago

centos 7.0 GCC 4.4.7 Python 3.5.2 |Anaconda 4.1.1 (64-bit)|

code:

import matplotlib
matplotlib.use('Agg')

from ggplot import *
p = ggplot(aes(x='date', y='beef'), data=meat)
a = p + geom_point()
a.save_as_base64()

error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/lib/python3.5/site-packages/ggplot/ggplot.py", line 574, in save_as_base64
    self.save(imgdata, width=width, height=height, dpi=dpi)
  File "/opt/anaconda3/lib/python3.5/site-packages/ggplot/ggplot.py", line 556, in save
    self.fig.savefig(filename)
  File "/opt/anaconda3/lib/python3.5/site-packages/matplotlib/figure.py", line 1572, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.5/site-packages/matplotlib/backend_bases.py", line 2244, in print_figure
    **kwargs)
  File "/opt/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py", line 556, in print_png
    _png.write_png(renderer._renderer, filename_or_obj, self.figure.dpi)
TypeError: string argument expected, got 'bytes'

what's happy? thanks!

waynenilsen commented 7 years ago

This is a python 2/3 compatibility issue. I can work on a PR if the maintainers would be open to it. I want this issue fixed as well.