Le 02/11/2014 09:34, Scott Lasley a écrit :
> I wish I could say that it was because of a deep understanding of the inner
> workings of matplotlib or a rock solid grasp of python 3's bytes vs strings,
> but it wasn't. fig.savefig threw the "TypeError: string argument expected,
> got 'bytes'" e
I wish I could say that it was because of a deep understanding of the inner
workings of matplotlib or a rock solid grasp of python 3's bytes vs strings,
but it wasn't. fig.savefig threw the "TypeError: string argument expected,
got 'bytes'" exception, so I figured BytesIO might work better wit
Well, the methodology is sufficient and efficient, I'm OK with that :)
Thanks for these additional information.
Regards,
Le 2 nov. 2014 09:34, "Scott Lasley" a écrit :
> I wish I could say that it was because of a deep understanding of the
> inner workings of matplotlib or a rock solid grasp of
Indeed, it works also for me with Python 3.3.5.
Could you explain the changes you made and the reasons behind the
byte/string encoding ?
Best regards,
2014-11-01 17:21 GMT+01:00 Scott Lasley :
> This works for me with python 3.4.2
>
> import matplotlib.pyplot as plt
> from io import BytesIO
> i
Many Thanks for your support.
It is Python 3.3.5 and matplotlib 1.4.0
I've also found that it worked with ByteIO(), but then I was stuck by the
encode/decode things. Thanks very much !
The traceback is below:
Traceback (most recent call last):
File "", line 1, in
runfile('/home/hash/exa
This works for me with python 3.4.2
import matplotlib.pyplot as plt
from io import BytesIO
import base64
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3])
sio = BytesIO()
fig.savefig(sio, format="png")
html = """
""".format(base64.encodebytes(sio.getvalue()).decode())
For python
Please post the entire traceback so that we can know the context of the
error message. Also, exactly which versions of matplotlib and python are
you using?
Ben Root
On Sat, Nov 1, 2014 at 7:37 AM, Julien Hillairet wrote:
> Dear all,
>
> I'm trying to write a html page content in which a png fig
Dear all,
I'm trying to write a html page content in which a png figure is generated
by matplotlib, with Python3.
However, the following piece of code does not work with matplotlib/Python3
(while it should work with Python2). The error is the following on
TypeError: string argument expected, got