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

Skip to content

Commit 9f62c21

Browse files
committed
numerous text fixes
svn path=/trunk/matplotlib/; revision=328
1 parent 6bd9aa4 commit 9f62c21

4 files changed

Lines changed: 42 additions & 13 deletions

File tree

CHANGELOG

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
New entries should be added at the top
22

3-
2004-05-31 Added renderer markteredgewidth attribute of Line2D. - ADS
3+
2004-06-02 Fixed text clipping to clip to axes - JDH
4+
5+
2004-06-02 Fixed leading newline text and multiple newline text - JDH
6+
7+
2004-06-02 Fixed plot_date to return lines - JDH
8+
9+
2004-06-01 Fixed plot to work with x or y having shape N,1 or 1,N - JDH
10+
11+
2004-05-31 Added renderer markeredgewidth attribute of Line2D. - ADS
12+
13+
14+
2004-05-29 Fixed tick label clipping to work with navigation.
415

516
2004-05-28 Added renderer grouping commands to support groups in
617
SVG/PS. - JDH

TODO

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

407407
-- add collections to lines
408408

409-
-- some strangeness in table when multiple saves are called
409+
-- some strangeness in table when multiple saves are called
410+
411+
-- use RGBA throughout lib

examples/multiline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from matplotlib.matlab import *
2+
23
plot(arange(10))
34
xlabel('this is a xlabel\n(with newlines!)')
45
ylabel('this is vertical\ntest', multialignment='center')

src/_backend_agg.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -808,16 +808,31 @@ RendererAgg::draw_text(const Py::Tuple& args) {
808808

809809
int x = Py::Int( args[1] );
810810
int y = Py::Int( args[2] );
811-
Py::SeqBase<Py::Object> rgba = Py::SeqBase<Py::Object>( args[3] );
812-
813-
double r = Py::Float( rgba[0] );
814-
double g = Py::Float( rgba[1] );
815-
double b = Py::Float( rgba[2] );
816-
double a = Py::Float( rgba[3] );
817-
818-
811+
Py::Object gc = args[3];
812+
813+
Py::Object o ( gc.getAttr( "_cliprect" ) );
814+
815+
bool useClip = o.ptr()!=Py_None;
816+
double l = 0;
817+
double b = 0;
818+
double r = width;
819+
double t = height;
820+
if (useClip) {
821+
Py::SeqBase<Py::Object> rect( o );
822+
823+
l = Py::Float(rect[0]) ;
824+
b = Py::Float(rect[1]) ;
825+
double w = Py::Float(rect[2]) ;
826+
double h = Py::Float(rect[3]) ;
827+
r = l+w;
828+
t = b+h;
829+
//std::cout << b << " " << h << " " << " " << t << std::endl;
830+
}
831+
832+
agg::rgba color = get_color(gc);
819833
pixfmt::color_type p;
820-
p.r = int(255*r); p.b = int(255*b); p.g = int(255*g); p.a = int(255*a);
834+
p.r = int(255*color.r); p.b = int(255*color.b);
835+
p.g = int(255*color.g); p.a = int(255*color.a);
821836

822837
//y = y-font->image.height;
823838
unsigned thisx, thisy;
@@ -826,8 +841,8 @@ RendererAgg::draw_text(const Py::Tuple& args) {
826841
for (size_t j=0; j<font->image.height; ++j) {
827842
thisx = i+x+font->image.offsetx;
828843
thisy = j+y+font->image.offsety;
829-
if (thisx<0 || thisx>=width) continue;
830-
if (thisy<0 || thisy>=height) continue;
844+
if (thisx<l || thisx>=r) continue;
845+
if (thisy<height-t || thisy>=height-b) continue;
831846
pixFmt->blend_pixel
832847
(thisx, thisy, p, font->image.buffer[i + j*font->image.width]);
833848
}

0 commit comments

Comments
 (0)