Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
luobuda opened this issue Dec 11, 2016 · 4 comments
Closed

Comments

@luobuda
Copy link

luobuda commented Dec 11, 2016

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]

@tacaswell
Copy link
Member

attn @Carreau The exception is actually coming out of IPython. Probably related to rkern/line_profiler#37

I can not reproduce this on linux with

import sys
sys.getdefaultencoding()
Out[2]:  'utf-8'
import locale
locale.getpreferredencoding()
Out[3]: 'UTF-8'

Are these different on your system?

I have included below the svg I get from running this code, can you open and display it using SVG on your system? Does your output include any non-ascii characters?

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Created with matplotlib (http://matplotlib.org/) -->
<svg height="288pt" version="1.1" viewBox="0 0 432 288" width="432pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <defs>
  <style type="text/css">
*{stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:100000;}
  </style>
 </defs>
 <g id="figure_1">
  <g id="patch_1">
   <path d="M 0 288 
L 432 288 
L 432 0 
L 0 0 
z
" style="fill:#ffffff;"/>
  </g>
  <g id="axes_1">
   <g id="patch_2">
    <path d="M 54 252 
L 388.8 252 
L 388.8 28.8 
L 54 28.8 
z
" style="fill:#ffffff;"/>
   </g>
   <g id="line2d_1">
    <path clip-path="url(#p0d4ccebf35)" d="M 54 140.4 
L 57.381818 121.739656 
L 60.763636 103.838295 
L 64.145455 87.424028 
L 67.527273 73.164482 
L 70.909091 61.639643 
L 74.290909 53.318267 
L 77.672727 48.538814 
L 81.054545 47.495681 
L 84.436364 50.231297 
L 87.818182 56.634394 
L 91.2 66.444535 
L 94.581818 79.262707 
L 97.963636 94.56755 
L 101.345455 111.736561 
L 104.727273 130.071416 
L 108.109091 148.826372 
L 111.490909 167.238596 
L 114.872727 184.5592 
L 118.254545 200.083693 
L 121.636364 213.180638 
L 125.018182 223.317336 
L 128.4 230.081492 
L 131.781818 233.197983 
L 135.163636 232.540052 
L 138.545455 228.134457 
L 141.927273 220.160391 
L 145.309091 208.942187 
L 148.690909 194.936128 
L 152.072727 178.711892 
L 155.454545 160.929376 
L 158.836364 142.311856 
L 162.218182 123.616575 
L 165.6 105.603936 
L 168.981818 89.006575 
L 172.363636 74.499568 
L 175.745455 62.672965 
L 179.127273 54.007796 
L 182.509091 48.856505 
L 185.890909 47.428612 
L 189.272727 49.782196 
L 192.654545 55.821527 
L 196.036364 65.300965 
L 199.418182 77.834947 
L 202.8 92.913672 
L 206.181818 109.923834 
L 209.563636 128.17357 
L 212.945455 146.920598 
L 216.327273 165.402411 
L 219.709091 182.867286 
L 223.090909 198.604867 
L 226.472727 211.975049 
L 229.854545 222.43402 
L 233.236364 229.556376 
L 236.618182 233.052426 
L 240 232.779973 
L 243.381818 228.750099 
L 246.763636 221.126713 
L 250.145455 210.219885 
L 253.527273 196.473234 
L 256.909091 180.445887 
L 260.290909 162.789731 
L 263.672727 144.222905 
L 267.054545 125.500588 
L 270.436364 107.384283 
L 273.818182 90.610844 
L 277.2 75.862507 
L 280.581818 63.739139 
L 283.963636 54.73384 
L 287.345455 49.212888 
L 290.727273 47.400839 
L 294.109091 49.371396 
L 297.490909 55.044409 
L 300.872727 64.189137 
L 304.254545 76.433631 
L 307.636364 91.279864 
L 311.018182 108.123988 
L 314.4 126.280891 
L 317.781818 145.012069 
L 321.163636 163.555657 
L 324.545455 181.157423 
L 327.927273 197.10144 
L 331.309091 210.739208 
L 334.690909 221.516031 
L 338.072727 228.993577 
L 341.454545 232.867708 
L 344.836364 232.980849 
L 348.218182 229.328399 
L 351.6 222.058915 
L 354.981818 211.468073 
L 358.363636 197.986641 
L 361.745455 182.162955 
L 365.127273 164.640622 
L 368.509091 146.132337 
L 371.890909 127.390898 
L 375.272727 109.178585 
L 378.654545 92.236157 
L 382.036364 77.252724 
L 385.418182 64.837715 
L 388.8 55.496092 
" style="fill:none;stroke:#0000ff;stroke-linecap:square;"/>
   </g>
   <g id="patch_3">
    <path d="M 388.8 252 
L 388.8 28.8 
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;"/>
   </g>
   <g id="patch_4">
    <path d="M 54 252 
L 388.8 252 
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;"/>
   </g>
   <g id="patch_5">
    <path d="M 54 28.8 
L 388.8 28.8 
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;"/>
   </g>
   <g id="patch_6">
    <path d="M 54 252 
L 54 28.8 
" style="fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;"/>
   </g>
   <g id="matplotlib.axis_1">
    <g id="xtick_1">
     <g id="line2d_2">
      <defs>
       <path d="M 0 0 
L 0 -4 
" id="m1577eb83ab" style="stroke:#000000;stroke-width:0.5;"/>
      </defs>
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_3">
      <defs>
       <path d="M 0 0 
L 0 4 
" id="m1e1a876abf" style="stroke:#000000;stroke-width:0.5;"/>
      </defs>
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_1">
      <!-- 0 -->
      <defs>
       <path d="M 31.78125 66.40625 
Q 24.171875 66.40625 20.328125 58.90625 
Q 16.5 51.421875 16.5 36.375 
Q 16.5 21.390625 20.328125 13.890625 
Q 24.171875 6.390625 31.78125 6.390625 
Q 39.453125 6.390625 43.28125 13.890625 
Q 47.125 21.390625 47.125 36.375 
Q 47.125 51.421875 43.28125 58.90625 
Q 39.453125 66.40625 31.78125 66.40625 
M 31.78125 74.21875 
Q 44.046875 74.21875 50.515625 64.515625 
Q 56.984375 54.828125 56.984375 36.375 
Q 56.984375 17.96875 50.515625 8.265625 
Q 44.046875 -1.421875 31.78125 -1.421875 
Q 19.53125 -1.421875 13.0625 8.265625 
Q 6.59375 17.96875 6.59375 36.375 
Q 6.59375 54.828125 13.0625 64.515625 
Q 19.53125 74.21875 31.78125 74.21875 
" id="BitstreamVeraSans-Roman-30"/>
      </defs>
      <g transform="translate(50.81875 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-30"/>
      </g>
     </g>
    </g>
    <g id="xtick_2">
     <g id="line2d_4">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="120.96" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_5">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="120.96" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_2">
      <!-- 2 -->
      <defs>
       <path d="M 19.1875 8.296875 
L 53.609375 8.296875 
L 53.609375 0 
L 7.328125 0 
L 7.328125 8.296875 
Q 12.9375 14.109375 22.625 23.890625 
Q 32.328125 33.6875 34.8125 36.53125 
Q 39.546875 41.84375 41.421875 45.53125 
Q 43.3125 49.21875 43.3125 52.78125 
Q 43.3125 58.59375 39.234375 62.25 
Q 35.15625 65.921875 28.609375 65.921875 
Q 23.96875 65.921875 18.8125 64.3125 
Q 13.671875 62.703125 7.8125 59.421875 
L 7.8125 69.390625 
Q 13.765625 71.78125 18.9375 73 
Q 24.125 74.21875 28.421875 74.21875 
Q 39.75 74.21875 46.484375 68.546875 
Q 53.21875 62.890625 53.21875 53.421875 
Q 53.21875 48.921875 51.53125 44.890625 
Q 49.859375 40.875 45.40625 35.40625 
Q 44.1875 33.984375 37.640625 27.21875 
Q 31.109375 20.453125 19.1875 8.296875 
" id="BitstreamVeraSans-Roman-32"/>
      </defs>
      <g transform="translate(117.77875 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-32"/>
      </g>
     </g>
    </g>
    <g id="xtick_3">
     <g id="line2d_6">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="187.92" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_7">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="187.92" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_3">
      <!-- 4 -->
      <defs>
       <path d="M 37.796875 64.3125 
L 12.890625 25.390625 
L 37.796875 25.390625 
z
M 35.203125 72.90625 
L 47.609375 72.90625 
L 47.609375 25.390625 
L 58.015625 25.390625 
L 58.015625 17.1875 
L 47.609375 17.1875 
L 47.609375 0 
L 37.796875 0 
L 37.796875 17.1875 
L 4.890625 17.1875 
L 4.890625 26.703125 
z
" id="BitstreamVeraSans-Roman-34"/>
      </defs>
      <g transform="translate(184.73875 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-34"/>
      </g>
     </g>
    </g>
    <g id="xtick_4">
     <g id="line2d_8">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="254.88" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_9">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="254.88" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_4">
      <!-- 6 -->
      <defs>
       <path d="M 33.015625 40.375 
Q 26.375 40.375 22.484375 35.828125 
Q 18.609375 31.296875 18.609375 23.390625 
Q 18.609375 15.53125 22.484375 10.953125 
Q 26.375 6.390625 33.015625 6.390625 
Q 39.65625 6.390625 43.53125 10.953125 
Q 47.40625 15.53125 47.40625 23.390625 
Q 47.40625 31.296875 43.53125 35.828125 
Q 39.65625 40.375 33.015625 40.375 
M 52.59375 71.296875 
L 52.59375 62.3125 
Q 48.875 64.0625 45.09375 64.984375 
Q 41.3125 65.921875 37.59375 65.921875 
Q 27.828125 65.921875 22.671875 59.328125 
Q 17.53125 52.734375 16.796875 39.40625 
Q 19.671875 43.65625 24.015625 45.921875 
Q 28.375 48.1875 33.59375 48.1875 
Q 44.578125 48.1875 50.953125 41.515625 
Q 57.328125 34.859375 57.328125 23.390625 
Q 57.328125 12.15625 50.6875 5.359375 
Q 44.046875 -1.421875 33.015625 -1.421875 
Q 20.359375 -1.421875 13.671875 8.265625 
Q 6.984375 17.96875 6.984375 36.375 
Q 6.984375 53.65625 15.1875 63.9375 
Q 23.390625 74.21875 37.203125 74.21875 
Q 40.921875 74.21875 44.703125 73.484375 
Q 48.484375 72.75 52.59375 71.296875 
" id="BitstreamVeraSans-Roman-36"/>
      </defs>
      <g transform="translate(251.69875 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-36"/>
      </g>
     </g>
    </g>
    <g id="xtick_5">
     <g id="line2d_10">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="321.84" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_11">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="321.84" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_5">
      <!-- 8 -->
      <defs>
       <path d="M 31.78125 34.625 
Q 24.75 34.625 20.71875 30.859375 
Q 16.703125 27.09375 16.703125 20.515625 
Q 16.703125 13.921875 20.71875 10.15625 
Q 24.75 6.390625 31.78125 6.390625 
Q 38.8125 6.390625 42.859375 10.171875 
Q 46.921875 13.96875 46.921875 20.515625 
Q 46.921875 27.09375 42.890625 30.859375 
Q 38.875 34.625 31.78125 34.625 
M 21.921875 38.8125 
Q 15.578125 40.375 12.03125 44.71875 
Q 8.5 49.078125 8.5 55.328125 
Q 8.5 64.0625 14.71875 69.140625 
Q 20.953125 74.21875 31.78125 74.21875 
Q 42.671875 74.21875 48.875 69.140625 
Q 55.078125 64.0625 55.078125 55.328125 
Q 55.078125 49.078125 51.53125 44.71875 
Q 48 40.375 41.703125 38.8125 
Q 48.828125 37.15625 52.796875 32.3125 
Q 56.78125 27.484375 56.78125 20.515625 
Q 56.78125 9.90625 50.3125 4.234375 
Q 43.84375 -1.421875 31.78125 -1.421875 
Q 19.734375 -1.421875 13.25 4.234375 
Q 6.78125 9.90625 6.78125 20.515625 
Q 6.78125 27.484375 10.78125 32.3125 
Q 14.796875 37.15625 21.921875 38.8125 
M 18.3125 54.390625 
Q 18.3125 48.734375 21.84375 45.5625 
Q 25.390625 42.390625 31.78125 42.390625 
Q 38.140625 42.390625 41.71875 45.5625 
Q 45.3125 48.734375 45.3125 54.390625 
Q 45.3125 60.0625 41.71875 63.234375 
Q 38.140625 66.40625 31.78125 66.40625 
Q 25.390625 66.40625 21.84375 63.234375 
Q 18.3125 60.0625 18.3125 54.390625 
" id="BitstreamVeraSans-Roman-38"/>
      </defs>
      <g transform="translate(318.65875 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-38"/>
      </g>
     </g>
    </g>
    <g id="xtick_6">
     <g id="line2d_12">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#m1577eb83ab" y="252.0"/>
      </g>
     </g>
     <g id="line2d_13">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#m1e1a876abf" y="28.8"/>
      </g>
     </g>
     <g id="text_6">
      <!-- 10 -->
      <defs>
       <path d="M 12.40625 8.296875 
L 28.515625 8.296875 
L 28.515625 63.921875 
L 10.984375 60.40625 
L 10.984375 69.390625 
L 28.421875 72.90625 
L 38.28125 72.90625 
L 38.28125 8.296875 
L 54.390625 8.296875 
L 54.390625 0 
L 12.40625 0 
z
" id="BitstreamVeraSans-Roman-31"/>
      </defs>
      <g transform="translate(382.4375 263.5984375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-31"/>
       <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-30"/>
      </g>
     </g>
    </g>
   </g>
   <g id="matplotlib.axis_2">
    <g id="ytick_1">
     <g id="line2d_14">
      <defs>
       <path d="M 0 0 
L 4 0 
" id="m4e90072c16" style="stroke:#000000;stroke-width:0.5;"/>
      </defs>
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="252.0"/>
      </g>
     </g>
     <g id="line2d_15">
      <defs>
       <path d="M 0 0 
L -4 0 
" id="ma96b45d74d" style="stroke:#000000;stroke-width:0.5;"/>
      </defs>
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="252.0"/>
      </g>
     </g>
     <g id="text_7">
      <!-- −0.6 -->
      <defs>
       <path d="M 10.59375 35.5 
L 73.1875 35.5 
L 73.1875 27.203125 
L 10.59375 27.203125 
z
" id="BitstreamVeraSans-Roman-2212"/>
       <path d="M 10.6875 12.40625 
L 21 12.40625 
L 21 0 
L 10.6875 0 
z
" id="BitstreamVeraSans-Roman-2e"/>
      </defs>
      <g transform="translate(25.7171875 254.759375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-2212"/>
       <use x="83.7890625" xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="147.412109375" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="179.19921875" xlink:href="#BitstreamVeraSans-Roman-36"/>
      </g>
     </g>
    </g>
    <g id="ytick_2">
     <g id="line2d_16">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="214.8"/>
      </g>
     </g>
     <g id="line2d_17">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="214.8"/>
      </g>
     </g>
     <g id="text_8">
      <!-- −0.4 -->
      <g transform="translate(25.7171875 217.559375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-2212"/>
       <use x="83.7890625" xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="147.412109375" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="179.19921875" xlink:href="#BitstreamVeraSans-Roman-34"/>
      </g>
     </g>
    </g>
    <g id="ytick_3">
     <g id="line2d_18">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="177.6"/>
      </g>
     </g>
     <g id="line2d_19">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="177.6"/>
      </g>
     </g>
     <g id="text_9">
      <!-- −0.2 -->
      <g transform="translate(25.7171875 180.359375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-2212"/>
       <use x="83.7890625" xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="147.412109375" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="179.19921875" xlink:href="#BitstreamVeraSans-Roman-32"/>
      </g>
     </g>
    </g>
    <g id="ytick_4">
     <g id="line2d_20">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="140.4"/>
      </g>
     </g>
     <g id="line2d_21">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="140.4"/>
      </g>
     </g>
     <g id="text_10">
      <!-- 0.0 -->
      <g transform="translate(34.096875 143.159375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="95.41015625" xlink:href="#BitstreamVeraSans-Roman-30"/>
      </g>
     </g>
    </g>
    <g id="ytick_5">
     <g id="line2d_22">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="103.2"/>
      </g>
     </g>
     <g id="line2d_23">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="103.2"/>
      </g>
     </g>
     <g id="text_11">
      <!-- 0.2 -->
      <g transform="translate(34.096875 105.959375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="95.41015625" xlink:href="#BitstreamVeraSans-Roman-32"/>
      </g>
     </g>
    </g>
    <g id="ytick_6">
     <g id="line2d_24">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="66.0"/>
      </g>
     </g>
     <g id="line2d_25">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="66.0"/>
      </g>
     </g>
     <g id="text_12">
      <!-- 0.4 -->
      <g transform="translate(34.096875 68.759375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="95.41015625" xlink:href="#BitstreamVeraSans-Roman-34"/>
      </g>
     </g>
    </g>
    <g id="ytick_7">
     <g id="line2d_26">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="54.0" xlink:href="#m4e90072c16" y="28.8"/>
      </g>
     </g>
     <g id="line2d_27">
      <g>
       <use style="stroke:#000000;stroke-width:0.5;" x="388.8" xlink:href="#ma96b45d74d" y="28.8"/>
      </g>
     </g>
     <g id="text_13">
      <!-- 0.6 -->
      <g transform="translate(34.096875 31.559375)scale(0.1 -0.1)">
       <use xlink:href="#BitstreamVeraSans-Roman-30"/>
       <use x="63.623046875" xlink:href="#BitstreamVeraSans-Roman-2e"/>
       <use x="95.41015625" xlink:href="#BitstreamVeraSans-Roman-36"/>
      </g>
     </g>
    </g>
   </g>
  </g>
 </g>
 <defs>
  <clipPath id="p0d4ccebf35">
   <rect height="223.2" width="334.8" x="54.0" y="28.8"/>
  </clipPath>
 </defs>
</svg>

@luobuda
Copy link
Author

luobuda commented Dec 12, 2016

@tacaswell thank you for your reply. I have read the issue last night.

import sys
sys.getdefaultencoding()
Out[2]:  'utf-8'
import locale
locale.getpreferredencoding()
Out[3]: 'cp936'

I modified \Anaconda3\Lib\site-packages\IPython\core\display.py

class SVG(DisplayObject):

    # wrap data in a property, which extracts the <svg> tag, discarding
    # document headers
    _data = None
    _read_flags = 'rb'           # add this line 

now it works. I‘m not sure it affects others or not.

@QuLogic
Copy link
Member

QuLogic commented Dec 12, 2016

Our SVGs all start with the encoding line that says it's utf-8; it appears that IPython is not respecting that. This isn't a bug in matplotlib and should be reported to IPython.

@Carreau
Copy link
Contributor

Carreau commented Dec 12, 2016

Thanks, I opened ipython/ipython#10086.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants