Created
February 28, 2013 18:54
-
-
Save anonymous/5059144 to your computer and use it in GitHub Desktop.
remove viewBox attrib and set size(svg_utils issue #1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as pyplot | |
from lxml import etree | |
#do some plotting | |
plt.savefig(fig_file) | |
width, height = '3.8in', '2.8in' | |
with file(fig_file, 'r') as fid: | |
tree = etree.parse(fid) | |
root = tree.getroot() | |
root.attrib.pop('viewBox') | |
root.attrib['width']=width | |
root.attrib['height']=height | |
with file(fig_file, 'w') as fid: | |
tree.write(fid, pretty_print=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment