Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fa4e26

Browse files
committed
major overhaul of text
svn path=/trunk/matplotlib/; revision=278
1 parent 400bc51 commit 9fa4e26

4 files changed

Lines changed: 27 additions & 4 deletions

File tree

TODO

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,6 @@
341341

342342
-- savefig to file handle.
343343

344-
-- add agg and and image generic tostring methods
344+
-- add agg and and image generic tostring methods
345+
346+
-- expose line set dashes

examples/alignment_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@
8282
transx=ax.xaxis.transAxis,
8383
transy=ax.yaxis.transAxis)
8484

85+
ax.text(left, top, 'rotated',
86+
horizontalalignment='center',
87+
verticalalignment='center',
88+
rotation=45,
89+
transx=ax.xaxis.transAxis,
90+
transy=ax.yaxis.transAxis)
91+
8592
axis('off')
86-
#savefig('alignment_test', dpi=300)
93+
savefig('alignment_test', dpi=300)
8794
show()

examples/dash_control.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
You can precisely specify dashes with an on/off ink rect sequence in
3+
points.
4+
"""
5+
from matplotlib.matlab import *
6+
7+
dashes = [5,2,10,5] # 5 points on, 2 off, 3 on, 1 off
8+
9+
l, = plot(arange(20), '--')
10+
l.set_dashes(dashes)
11+
#savefig('dash_control')
12+
show()

src/_backend_agg.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,11 @@ RendererAgg::draw_lines(const Py::Tuple& args) {
316316
dash_t dash(path);
317317
agg::conv_stroke<dash_t> stroke(dash);
318318
double on, off;
319-
for (size_t i=0; i<N/2; i+=2) {
319+
for (size_t i=0; i<N/2; i+=1) {
320+
320321
on = points_to_pixels_snapto(dashSeq[2*i]);
321322
off = points_to_pixels_snapto(dashSeq[2*i+1]);
323+
//std::cout << "agg setting" << on << " " << off << std::endl;
322324
dash.add_dash(on, off);
323325
}
324326
stroke.line_cap(cap);
@@ -371,7 +373,7 @@ RendererAgg::draw_text(const Py::Tuple& args) {
371373
if (j+y>=height) continue;
372374

373375
pixFmt->blend_pixel
374-
(i+x, j+y, p, font->image.buffer[i + j*font->image.width]);
376+
(i+x, y+j, p, font->image.buffer[i + j*font->image.width]);
375377
}
376378
}
377379
return Py::Object();

0 commit comments

Comments
 (0)