Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d78ae6

Browse files
committed
STY: StringIO instead of BytesIO in svg examples
As svg is a string format, use `StringIO` as the temporary buffer in svg examples.
1 parent 6461fd9 commit 4d78ae6

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

examples/misc/svg_filter_line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
ax.set_ylim(0., 1.)
5353

5454
# save the figure as a string in the svg format.
55-
from io import BytesIO
56-
f = BytesIO()
55+
from io import StringIO
56+
f = StringIO()
5757
plt.savefig(f, format="svg")
5858

5959

examples/misc/svg_filter_pie.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343

4444
# save
45-
from io import BytesIO
46-
f = BytesIO()
45+
from io import StringIO
46+
f = StringIO()
4747
plt.savefig(f, format="svg")
4848

4949
import xml.etree.cElementTree as ET

examples/user_interfaces/svg_histogram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import numpy as np
3636
import matplotlib.pyplot as plt
3737
import xml.etree.ElementTree as ET
38-
from io import BytesIO
38+
from io import StringIO
3939
import json
4040

4141
plt.rcParams['svg.embed_char_paths'] = 'none'
@@ -76,7 +76,7 @@
7676
t.set_gid('leg_text_%d' % i)
7777

7878
# Save SVG in a fake file object.
79-
f = BytesIO()
79+
f = StringIO()
8080
plt.savefig(f, format="svg")
8181

8282
# Create XML tree from the SVG file.

examples/user_interfaces/svg_tooltip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import matplotlib.pyplot as plt
2626
import xml.etree.ElementTree as ET
27-
from io import BytesIO
27+
from io import StringIO
2828

2929
ET.register_namespace("", "http://www.w3.org/2000/svg")
3030

@@ -72,7 +72,7 @@
7272
ax.set_ylim(-30, 30)
7373
ax.set_aspect('equal')
7474

75-
f = BytesIO()
75+
f = StringIO()
7676
plt.savefig(f, format="svg")
7777

7878
# --- Add interactivity ---

0 commit comments

Comments
 (0)