8000 impl snapto for len(2) lines only · matplotlib/matplotlib@2f5ba91 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f5ba91

Browse files
committed
impl snapto for len(2) lines only
svn path=/trunk/matplotlib/; revision=1359
1 parent 3f26159 commit 2f5ba91

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

.matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +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 # experimental, broken
126+
text.usetex : True # experimental, broken
127127

128128
### AXES
129129
# default face and edge color, default tick sizes,

lib/matplotlib/texmanager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def get_image(self, tex, fontsize=10, dpi=80, rgb=(0,0,0)):
216216

217217
if im is None:
218218
# skip cacheing while debugging
219-
pngfile = self.make_png(tex, dpi, force=True)
219+
pngfile = self.make_png(tex, dpi, force=False)
220220
X = readpng(pngfile)
221221
# To compare my results with the result of using dvipng's,
222222
# change this to 'if 0:' and uncomment the third "command"
@@ -226,8 +226,8 @@ def get_image(self, tex, fontsize=10, dpi=80, rgb=(0,0,0)):
226226
# I try and recover the alpha information
227227
if 1:
228228
alpha = 1-X[:,:,0]
229-
visible = alpha>0
230-
print 'min/max', min(ravel(alpha)), max(ravel(alpha))
229+
#visible = alpha>0
230+
#print 'min/max', min(ravel(alpha)), max(ravel(alpha))
231231
Z = zeros(X.shape, Float)
232232
Z[:,:,0] = r
233233
Z[:,:,1] = g

lib/matplotlib/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ def draw(self, renderer):
324324
x, y = self._transform.xy_tup((x, y))
325325
if renderer.flipy():
326326
y = canvash-y
327-
renderer.draw_text(gc, x, y, line,
328-
self._fontproperties, angle, ismath)
327+
renderer.draw_tex(gc, x, y, line,
328+
self._fontproperties, angle)
329329
return
330330

331331
for line, wh, x, y in info:

src/_backend_agg.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,8 @@ RendererAgg::draw_lines(const Py::Tuple& args) {
10011001

10021002
double lastx(-2.0), lasty(-2.0);
10031003

1004+
bool snapto = Nx==2;
1005+
10041006
for (size_t i=0; i<Nx; i++) {
10051007
thisx = *(double *)(xa->data + i*xa->strides[0]);
10061008
thisy = *(double *)(ya->data + i*ya->strides[0]);
@@ -1022,11 +1024,15 @@ RendererAgg::draw_lines(const Py::Tuple& args) {
10221024
//don't render line segments less that on pixel long!
10231025
if (!moveto && (i>0) && fabs(thisx-lastx)<1.0 && fabs(thisy-lasty)<1.0) {
10241026
continue;
1025-
}
1026-
thisx = (int)thisx + 0.5;
1027-
thisy = (int)thisy + 0.5;
1027+
}
1028+
10281029
lastx = thisx;
10291030
lasty = thisy;
1031+
if (snapto) {
1032+
thisx = (int)thisx + 0.5;
1033+
thisy = (int)thisy + 0.5;
1034+
}
1035+
10301036
if (moveto)
10311037
path.move_to(thisx, thisy);
10321038
else

0 commit comments

Comments
 (0)
0