X Tutup
Skip to content

UnicodeDecodeError when using matplotlib save SVG file and open it again #7611

@luobuda

Description

@luobuda

I'm study matplotlib on win7 32-bit, matplotlib1.5.3, python3.5

when i run some sample code:

%matplotlib inline

import matplotlib
import matplotlib.pylab as plt
import numpy
from IPython.display import Image, SVG

fig, ax = plt.subplots()
t = numpy.linspace(0, 10, 100)
ax.plot(t, numpy.cos(t)*numpy.sin(t))
plt.savefig("test.svg", format="svg");

SVG(filename="test.svg")

in jupyter notebook.

I get error:

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-1-6ba7bf4bed8f> in <module>()
     15 plt.savefig("test.svg", format="svg");
     16 
---> 17 SVG(filename="test.svg")

D:\Program Files\Anaconda3\lib\site-packages\IPython\core\display.py in __init__(self, data, url, filename)
    392         self.filename = None if filename is None else unicode_type(filename)
    393 
--> 394         self.reload()
    395         self._check_data()
    396 

D:\Program Files\Anaconda3\lib\site-packages\IPython\core\display.py in reload(self)
    411         if self.filename is not None:
    412             with open(self.filename, self._read_flags) as f:
--> 413                 self.data = f.read()
    414         elif self.url is not None:
    415             try:

UnicodeDecodeError: 'gbk' codec can't decode byte 0x92 in position 13125: illegal multibyte sequence

I read some issuses about UnicodeDecodeError but can't solve it,can anyone help me?

[TAC edited to add markup]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup