Fix ImportError: No module named 'StringIO' on Python 3 #5788

Merged
merged 4 commits into from Jan 7, 2016
@@ -52,8 +52,8 @@
ax.set_ylim(0., 1.)
# save the figure as a string in the svg format.
-from StringIO import StringIO
-f = StringIO()
+from io import BytesIO
+f = BytesIO()
plt.savefig(f, format="svg")
@@ -42,8 +42,8 @@
# save
-from StringIO import StringIO
-f = StringIO()
+from io import BytesIO
+f = BytesIO()
plt.savefig(f, format="svg")
import xml.etree.cElementTree as ET
@@ -35,7 +35,7 @@
import numpy as np
import matplotlib.pyplot as plt
import xml.etree.ElementTree as ET
-from StringIO import StringIO
+from io import BytesIO
import json
plt.rcParams['svg.embed_char_paths'] = 'none'
@@ -76,7 +76,7 @@
t.set_gid('leg_text_%d' % i)
# Save SVG in a fake file object.
-f = StringIO()
+f = BytesIO()
plt.savefig(f, format="svg")
# Create XML tree from the SVG file.
@@ -24,7 +24,7 @@
import matplotlib.pyplot as plt
import xml.etree.ElementTree as ET
-from StringIO import StringIO
+from io import BytesIO
ET.register_namespace("", "http://www.w3.org/2000/svg")
@@ -72,7 +72,7 @@
ax.set_ylim(-30, 30)
ax.set_aspect('equal')
-f = StringIO()
+f = BytesIO()
plt.savefig(f, format="svg")
# --- Add interactivity ---