Hello, below I've included my script for plotting some data, and a small
amount of the data itself.
I plot the data to several different file types via pyplot.savefig().
For each of eps, pdf, and png, it works fine. With svg it throws this
error, any ideas why?:
harb@joan:~/Documents/DATA/ApplicationData/python-script$
./T-plots-modelvdata.py
Traceback (most recent call last):
File "./T-plots-modelvdata.py", line 58, in <module>
plt.savefig(directory + 'data-and-models.svg')
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/pyplot.py",
line 363, in savefig
return fig.savefig(*args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/figure.py",
line 1084, in savefig
self.canvas.print_figure(*args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_wxagg.py",
line 100, in print_figure
FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backend_bases.py",
line 1923, in print_figure
**kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backend_bases.py",
line 1754, in print_svg
return svg.print_svg(*args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_svg.py",
line 867, in print_svg
return self._print_svg(filename, svgwriter, fh_to_close, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_svg.py",
line 902, in _print_svg
self.figure.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/figure.py",
line 798, in draw
func(*args)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/axes.py",
line 1946, in draw
a.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/legend.py",
line 430, in draw
self._legend_box.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/offsetbox.py",
line 240, in draw
c.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/offsetbox.py",
line 240, in draw
c.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/offsetbox.py",
line 240, in draw
c.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/offsetbox.py",
line 240, in draw
c.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/offsetbox.py",
line 678, in draw
self._text.draw(renderer)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/text.py",
line 571, in draw
self._fontproperties, angle)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_svg.py",
line 587, in draw_tex
self.draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/backends/backend_svg.py",
line 541, in draw_text_as_path
path = Path(*glyph_path)
File
"/usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-x86_64.egg/matplotlib/path.py",
line 121, in __init__
assert vertices.ndim == 2
AssertionError
SCRIPT (yes there are some ugly bits):
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
# Set matplotlib to use LaTeX text handling:
rc('text', usetex=True)
rc('font', family='serif')
# Data file format: depth, temperature, depth, temperature, ...
directory = '~/bores/'
filename = directory + 'data-and-models.txt'
tdata = np.genfromtxt(filename,
skip_header=2, delimiter='\t', comments='#',
missing_values='', filling_values=np.nan)
# Get bore names and IDs:
with open(filename,'rU') as f:
bores = f.readline().rstrip().split('\t')
headers = f.readline().rstrip().split('\t')
for column in range(0, np.shape(tdata)[1], 2):
# Plots temperature on x, depth on y:
if bores[column+1] in ('T (q=70)', 'data'):
plt.plot(
tdata[:, column + 1],
tdata[:, column],
label=bores[column] + ' ' + bores[column + 1])
# titivate plot:
plt.title("Borehole data and model comparison")
plt.xlim(10,80)
plt.ylim(-1500,0)
plt.grid(True)
plt.xlabel(r'Temperature (\textcelsius)')
plt.ylabel(r'Depth ($mGL$)')
plt.legend()
plt.savefig(directory + 'data-and-models.pdf')
plt.savefig(directory + 'data-and-models.eps')
plt.savefig(directory + 'data-and-models.png')
#plt.savefig(directory + 'data-and-models.svg')
DATA SAMPLE (it's tab separated, hope they don't get converted to spaces):
DST fluid recovery data Precision log data Stratigraphy model
T (q=65)
Stratigraphy model T (q=70) Stratigraphy model T (q=75)
Lithology
model T (q=65) Lithology model T (q=70) Lithology model T (q=75)
Depth Temperature Depth Temperature Depth Temperature Depth
Temperature Depth Temperature Depth Temperature Depth
Temperature Depth
Temperature
-444.53 39.72 0 12.46 0 15 0 15 0 15
0.0 15 0.0 15 0.0 15
-876.53 55.81 -1.02 12.35 -19.75 15.6428849105 -19.75 15.6923375959
-19.75 15.7417902813 -16.3 15.541943734 -16.3 15.5836317136 -16.3
15.6253196931
-1395.35 77.08 -2.04 12.32 -126.75 22.4731381074 -126.75
23.0479948849 -126.75 23.6228516624 -19.8 15.6428849105 -19.8
15.6923375959 -19.8 15.7417902813
-3.06 12.31 -144.3 22.8533881074 -144.3 23.4574948849
-144.3
24.0616016624 -42.3 18.5743849105 -42.3 18.8493375959 -42.3
19.1242902813
-4.08 12.34 -1439.3 67.1560196864 -1439.3 71.1680212007
-1439.3
75.180022715 -46.3 18.727326087 -46.3 19.0140434783 -46.3
19.3007608696
-5.1 12.34
-61.3 19.1512391304 -61.3 19.4705652174 -61.3
19.7898913043
-6.12 12.6
-69.3 19.4571214834 -69.3 19.7999769821 -69.3
20.1428324808
-7.13 12.88
-72.3 19.8471214834 -72.3 20.2199769821 -72.3
20.5928324808
-8.15 13.05
-77.3 20.038297954 -77.3 20.425859335 -77.3
20.8134207161
-9.17 13.2
-87.3 21.338297954 -87.3 21.825859335 -87.3 22.3134207161
-10.19 13.35
-89.3 21.4147685422 -89.3 21.9082122762 -89.3
22.4016560102
-11.21 13.47
-126.8 22.4731381074 -126.8 23.0479948849 -126.8
23.6228516624
-12.23 13.61
-144.8 22.8533881074 -144.8 23.4574948849 -144.8
24.0616016624
-13.25 13.95
-216.3 25.3011512653 -216.3 26.0935475165 -216.3
26.8859437677
-14.27 14.2
-380.3 30.9116775811 -380.3 32.1356527796 -380.3
33.3596279782
-15.29 14.62
-392.3 31.3222038969 -392.3 32.5777580428 -392.3
33.8333121887
-16.31 14.81
-419.9 32.2664144232 -419.9 33.5946001481 -419.9
34.9227858729
-17.33 14.94
-436.3 32.8274670548 -436.3 34.1988106744 -436.3
35.570154294
-18.35 16.01
-452.9 33.3960460022 -452.9 34.8111264639 -452.9
36.2262069256
-19.36 16.61
-453.3 33.4090460022 -453.3 34.8251264639 -453.3
36.2412069256
-20.38 16.95
-509.3 35.3248354758 -509.3 36.8882843586 -509.3
38.4517332414
-21.4 17.24
-636.3 39.6695723179 -636.3 41.567231727 -636.3
43.4648911361
-22.42 17.49
-746.3 43.4327302127 -746.3 45.619863306 -746.3
47.8069963992
-23.44 17.66
-770.3 44.2537828443 -770.3 46.5040738323 -770.3
48.7543648203
-24.46 17.85
-886.3 48.2222038969 -886.3 50.7777580428 -886.3
53.3333121887
-25.48 18.01
-958.3 50.6853617916 -958.3 53.4303896218 -958.3
56.1754174519
-26.5 18.17
-1160.3 57.5958881074 -1160.3 60.8724948849 -1160.3
64.1491016624
-27.52 18.31
-1324.3 63.2064144232 -1324.3 66.9146001481
-1324.3 70.6227858729
-28.54 18.52
-1379.3 65.0879933706 -1379.3 68.9409159375
-1379.3 72.7938385045
-29.56 18.65
-1412.3 66.216940739 -1412.3 70.1567054112 -1412.3
74.0964700835
-30.58 18.81
-1427.3 66.7300986337 -1427.3 70.7093369902
-1427.3 74.6885753466
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users