8000 added psfrag latex backend · matplotlib/matplotlib@f20cff5 · GitHub
[go: up one dir, main page]

Skip to content

Commit f20cff5

Browse files
committed
added psfrag latex backend
svn path=/trunk/matplotlib/; revision=1349
1 parent 9dcfadb commit f20cff5

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

.matplotlibrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Cour
123123
# http://matplotlib.sourceforge.net/matplotlib.text.html for more
124124
# information on text properties
125125
text.color : black
126-
text.usetex : False
127-
126+
text.usetex : False # experimental, broken
128127

129128
### AXES
130129
# default face and edge color, default tick sizes,

examples/tex_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
32
from pylab import *
43
figure(1)
54
ax = axes([0.1, 0.1, 0.8, 0.7])
@@ -9,7 +8,7 @@
98

109
xlabel('time (s)')
1110
ylabel('voltage (mV)')
12-
title(r"\TeX\ is Number $e^{-i\pi}$!", fontsize=30)
11+
title(r"\TeX\ is Number $e^{-i\pi}$!", color='red', fontsize=20)
1312
grid(True)
1413
savefig('tex_demo')
1514
show()

lib/matplotlib/backends/backend_latex.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
3434
pos = _nums_to_str(x, y)
3535
thetext = 'psmarker%d' % self.textcnt
3636
setcolor = '%1.3f %1.3f %1.3f setrgbcolor' % gc.get_rgb()
37-
38-
self.psfrag.append(r'\psfrag{%s}[bl][bl][1][%f]{%s}'%(thetext, angle, s))
37+
fontsize = prop.get_size_in_points()
38+
scale = float(fontsize/10.0)
39+
self.psfrag.append(r'\psfrag{%s}[bl][bl][%f][%f]{%s}'%(thetext, scale, angle, s))
3940
ps = """\
4041
gsave
41-
/CMR10 findfont
42-
12 scalefont
43-
setfont
4442
%(pos)s moveto
45-
(%(thetext)s)
4643
%(setcolor)s
44+
(%(thetext)s)
4745
show
4846
grestore
4947
""" % locals()

0 commit comments

Comments
 (0)
0