You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
|
2
(1) |
3
(4) |
4
(9) |
5
(14) |
6
(8) |
7
(14) |
8
(1) |
9
(2) |
10
(9) |
11
(5) |
12
(11) |
13
(4) |
14
(4) |
15
(1) |
16
|
17
(1) |
18
(2) |
19
(4) |
20
(10) |
21
(3) |
22
(3) |
23
(2) |
24
(8) |
25
(6) |
26
(5) |
27
|
28
(3) |
29
|
30
(3) |
|
|
|
|
|
|
Revision: 3780 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3780&view=rev Author: dsdale Date: 2007年09月04日 13:49:00 -0700 (2007年9月04日) Log Message: ----------- added missing import statement to config/rcparams.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/rcparams.py Modified: trunk/matplotlib/lib/matplotlib/config/rcparams.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcparams.py 2007年09月04日 20:27:36 UTC (rev 3779) +++ trunk/matplotlib/lib/matplotlib/config/rcparams.py 2007年09月04日 20:49:00 UTC (rev 3780) @@ -1,4 +1,5 @@ import os +import sys import warnings import checkdep @@ -193,4 +194,4 @@ Restore the default rc params - the ones that were created at matplotlib load time """ - rcParams.update(rcParamsDefault) \ No newline at end of file + rcParams.update(rcParamsDefault) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3779 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3779&view=rev Author: jouni Date: 2007年09月04日 13:27:36 -0700 (2007年9月04日) Log Message: ----------- More work on supporting Type 1 fonts in PDF. Sort of works now. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/dviread.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007年09月04日 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/CHANGELOG 2007年09月04日 20:27:36 UTC (rev 3779) @@ -1,3 +1,7 @@ +2007年09月04日 Embedding Type 1 fonts in PDF, and thus usetex support + via dviread, sort of works. To test, enable it by + renaming _draw_tex to draw_tex. - JKS + 2007年09月03日 Added ability of errorbar show limits via caret or arrowhead ends on the bars; patch by Manual Metz. - EF Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007年09月04日 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007年09月04日 20:27:36 UTC (rev 3779) @@ -581,7 +581,7 @@ 'CapHeight': 1000, # default guess if missing from AFM file 'XHeight': afmdata.get_xheight(), 'FontFile': fontfileObject, - 'FontFamily': Name(familyname), + 'FontFamily': familyname, #'FontWeight': a number where 400 = Regular, 700 = Bold } try: @@ -1422,7 +1422,7 @@ self.file.output(Op.grestore) def _draw_tex(self, gc, x, y, s, prop, angle): - # Rename to draw_tex to enable, but it doesn't work at the moment + # Rename to draw_tex to enable texmanager = self.get_texmanager() fontsize = prop.get_size_in_points() @@ -1606,6 +1606,19 @@ return draw_text_woven(chunks) def get_text_width_height_descent(self, s, prop, ismath): + if rcParams['text.usetex']: + texmanager = self.get_texmanager() + fontsize = prop.get_size_in_points() + dvifile = texmanager.make_dvi(s, fontsize) + dvi = dviread.Dvi(dvifile, 72) + text, boxes = iter(dvi).next() + # TODO: better bounding box -- this is not quite right: + l = min(p[0] for p in text+boxes) + r = max(p[0] for p in text+boxes) + fontsize + b = min(p[1] for p in text+boxes) + t = max(p[1] for p in text+boxes) + fontsize + # (not to even mention finding the baseline) + return r-l, t-b, t-b if ismath: w, h, d, glyphs, rects, used_characters = \ self.mathtext_parser.parse(s, 72, prop) Modified: trunk/matplotlib/lib/matplotlib/dviread.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dviread.py 2007年09月04日 19:52:23 UTC (rev 3778) +++ trunk/matplotlib/lib/matplotlib/dviread.py 2007年09月04日 20:27:36 UTC (rev 3779) @@ -15,6 +15,8 @@ ... """ +# TODO: support for TeX virtual fonts (*.vf) which are a dvi-like format + import matplotlib import matplotlib.cbook as mpl_cbook import os This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3778 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3778&view=rev Author: mdboom Date: 2007年09月04日 12:52:23 -0700 (2007年9月04日) Log Message: ----------- Simplify and fix a memory leak. Modified Paths: -------------- trunk/matplotlib/src/ft2font.cpp trunk/matplotlib/src/ft2font.h Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2007年09月04日 19:29:45 UTC (rev 3777) +++ trunk/matplotlib/src/ft2font.cpp 2007年09月04日 19:52:23 UTC (rev 3778) @@ -42,14 +42,14 @@ FT_Library _ft2Library; -FT2Image::FT2Image() : - _isDirty(true), - _buffer(NULL), - _width(0), _height(0), - _rgbCopy(NULL), - _rgbaCopy(NULL) { - _VERBOSE("FT2Image::FT2Image"); -} +// FT2Image::FT2Image() : +// _isDirty(true), +// _buffer(NULL), +// _width(0), _height(0), +// _rgbCopy(NULL), +// _rgbaCopy(NULL) { +// _VERBOSE("FT2Image::FT2Image"); +// } FT2Image::FT2Image(unsigned long width, unsigned long height) : _isDirty(true), @@ -65,75 +65,28 @@ _VERBOSE("FT2Image::~FT2Image"); delete [] _buffer; _buffer=NULL; + delete _rgbCopy; + delete _rgbaCopy; } void FT2Image::resize(unsigned long width, unsigned long height) { size_t numBytes = width*height; - if (_width != width || _height != height) { + if (width != _width || height != _height) { + if (numBytes > _width*_height) { + delete [] _buffer; + _buffer = new unsigned char [numBytes]; + } + _width = width; _height = height; - - delete [] _buffer; - _buffer = new unsigned char [numBytes]; } - for (size_t n=0; n<numBytes; n++) - _buffer[n] = 0; + memset(_buffer, 0, numBytes); _isDirty = true; } -char FT2Image::resize__doc__[] = -"resize(width, height)\n" -"\n" -"Resize the dimensions of the image (it is cleared in the process).\n" -; -Py::Object -FT2Image::py_resize(const Py::Tuple & args) { - _VERBOSE("FT2Image::resize"); - - args.verify_length(2); - - long x0 = Py::Int(args[0]); - long y0 = Py::Int(args[1]); - - resize(x0, y0); - - return Py::Object(); -} - -void FT2Image::clear() { - _VERBOSE("FT2Image::clear"); - - _width = 0; - _height = 0; - _isDirty = true; - delete [] _buffer; - _buffer = NULL; - if (_rgbCopy) { - delete _rgbCopy; - _rgbCopy = NULL; - } - if (_rgbaCopy) { - delete _rgbaCopy; - _rgbaCopy = NULL; - } -} -char FT2Image::clear__doc__[] = -"clear()\n" -"\n" -"Clear the contents of the image.\n" -; -Py::Object -FT2Image::py_clear(const Py::Tuple & args) { - args.verify_length(0); - - clear(); - - return Py::Object(); -} - void FT2Image::draw_bitmap( FT_Bitmap* bitmap, FT_Int x, @@ -345,9 +298,7 @@ unsigned char *dst = _rgbaCopy->_buffer; while (src != src_end) { - *dst++ = 0; - *dst++ = 0; - *dst++ = 0; + dst += 3; *dst++ = *src++; } } @@ -824,8 +775,7 @@ _VERBOSE("FT2Font::clear"); args.verify_length(0); - if (image) - image->clear(); + delete image; angle = 0.0; @@ -1194,11 +1144,9 @@ size_t width = (string_bbox.xMax-string_bbox.xMin) / 64 + 2; size_t height = (string_bbox.yMax-string_bbox.yMin) / 64 + 2; - if (!image) { - image = new FT2Image(width, height); - } else { - image->resize(width, height); - } + Py_XDECREF(image); + image = NULL; + image = new FT2Image(width, height); for ( size_t n = 0; n < glyphs.size(); n++ ) { @@ -1764,10 +1712,6 @@ behaviors().name("FT2Image"); behaviors().doc("FT2Image"); - add_varargs_method("clear", &FT2Image::py_clear, - FT2Image::clear__doc__); - add_varargs_method("resize", &FT2Image::py_resize, - FT2Image::resize__doc__); add_varargs_method("write_bitmap", &FT2Image::py_write_bitmap, FT2Image::write_bitmap__doc__); add_varargs_method("draw_rect", &FT2Image::py_draw_rect, Modified: trunk/matplotlib/src/ft2font.h =================================================================== --- trunk/matplotlib/src/ft2font.h 2007年09月04日 19:29:45 UTC (rev 3777) +++ trunk/matplotlib/src/ft2font.h 2007年09月04日 19:52:23 UTC (rev 3778) @@ -22,14 +22,12 @@ // the freetype string rendered into a width, height buffer class FT2Image : public Py::PythonExtension<FT2Image> { public: - FT2Image(); + // FT2Image(); FT2Image(unsigned long width, unsigned long height); ~FT2Image(); static void init_type(); - void resize(unsigned long width, unsigned long height); - void clear(); void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y); void write_bitmap(const char* filename) const; void draw_rect(unsigned long x0, unsigned long y0, @@ -41,10 +39,6 @@ unsigned int get_height() const { return _height; }; const unsigned char *const get_buffer() const { return _buffer; }; - static char clear__doc__ []; - Py::Object py_clear(const Py::Tuple & args); - static char resize__doc__ []; - Py::Object py_resize(const Py::Tuple & args); static char write_bitmap__doc__ []; Py::Object py_write_bitmap(const Py::Tuple & args); static char draw_rect__doc__ []; @@ -71,6 +65,8 @@ void makeRgbCopy(); void makeRgbaCopy(); + + void resize(unsigned long width, unsigned long height); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3777 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3777&view=rev Author: mdboom Date: 2007年09月04日 12:29:45 -0700 (2007年9月04日) Log Message: ----------- Better error messages. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007年09月04日 19:00:18 UTC (rev 3776) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007年09月04日 19:29:45 UTC (rev 3777) @@ -138,7 +138,7 @@ Combine, Group, Optional, Forward, NotAny, alphas, nums, alphanums, \ StringStart, StringEnd, ParseFatalException, FollowedBy, Regex, \ operatorPrecedence, opAssoc, ParseResults, Or, Suppress, oneOf, \ - ParseException, MatchFirst, NoMatch + ParseException, MatchFirst, NoMatch, Empty from matplotlib.afm import AFM from matplotlib.cbook import enumerate, iterable, Bunch, get_realpath_and_stat, \ @@ -1787,6 +1787,14 @@ ############################################################################## # PARSER +def Error(msg): + def raise_error(s, loc, toks): + raise ParseFatalException(msg) + + empty = Empty() + empty.setParseAction(raise_error) + return empty + class Parser(object): _binary_operators = Set(r''' + * @@ -1887,9 +1895,10 @@ ).setParseAction(self.space).setName('space') customspace =(Literal(r'\hspace') - + lbrace - + float - + rbrace + + (( lbrace + + float + + rbrace + ) | Error(r"Expected \hspace{n}")) ).setParseAction(self.customspace).setName('customspace') symbol =(Regex(r"([a-zA-Z0-9 +\-*/<>=:,.;!'@()])|(\\[%${}\[\]])") @@ -1926,8 +1935,8 @@ bslash + Literal("frac") ) - + group - + group + + ((group + group) + | Error(r"Expected \frac{num}{den}")) ).setParseAction(self.frac).setName("frac") sqrt = Group( @@ -1946,7 +1955,7 @@ + Suppress(Literal("]")), default = None ) - + group + + (group | Error("Expected \sqrt{value}")) ).setParseAction(self.sqrt).setName("sqrt") placeable <<(accent @@ -1955,7 +1964,7 @@ ^ group ^ frac ^ sqrt - ) + ) | Error("Expected symbol or group") simple <<(space | customspace @@ -1983,12 +1992,12 @@ leftDelim = oneOf(r"( [ { \lfloor \langle \lceil") rightDelim = oneOf(r") ] } \rfloor \rangle \rceil") autoDelim <<(Suppress(Literal(r"\left")) - + (leftDelim | ambiDelim) + + ((leftDelim | ambiDelim) | Error("Expected a delimiter")) + Group( autoDelim ^ OneOrMore(simple)) + Suppress(Literal(r"\right")) - + (rightDelim | ambiDelim) + + ((rightDelim | ambiDelim) | Error("Expected a delimiter")) ) math = OneOrMore( @@ -2007,7 +2016,8 @@ + ZeroOrMore( Suppress(math_delim) + math - + Suppress(math_delim) + + (Suppress(math_delim) + | Error("Expected end of math '$'")) + non_math ) ) + StringEnd() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3776 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3776&view=rev Author: mdboom Date: 2007年09月04日 12:00:18 -0700 (2007年9月04日) Log Message: ----------- Add support for arbitrary angles of rotation on mathtext in Agg backend. Uses agg to rotate the raster of the text. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/ft2font.cpp trunk/matplotlib/src/ft2font.h Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007年09月04日 19:00:18 UTC (rev 3776) @@ -174,17 +174,10 @@ 'debug-annoying') ox, oy, width, height, descent, font_image, used_characters = \ self.mathtext_parser.parse(s, self.dpi.get(), prop) - - if angle == 90: - width, height = height, width - ox, oy = oy, ox - x = int(x) - width + ox - y = int(y) - height + oy - font_image.rotate() - else: - x = int(x) + ox - y = int(y) - height + oy - self._renderer.draw_text_image(font_image, x, y + 1, gc) + + x = int(x) + ox + y = int(y) - oy + self._renderer.draw_text_image(font_image, x, y + 1, angle, gc) if 0: self._renderer.draw_rectangle(gc, None, int(x), @@ -205,12 +198,14 @@ if len(s) == 1 and ord(s) > 127: font.load_char(ord(s), flags=LOAD_DEFAULT) else: - font.set_text(s, angle, flags=LOAD_DEFAULT) + font.set_text(s, 0, flags=LOAD_DEFAULT) font.draw_glyphs_to_bitmap() #print x, y, int(x), int(y) - self._renderer.draw_text_image(font.get_image(), int(x), int(y) + 1, gc) + # We pass '0' for angle here, since is has already been rotated + # (in vector space) in the above call to font.set_text. + self._renderer.draw_text_image(font.get_image(), int(x), int(y) + 1, angle, gc) def get_text_width_height_descent(self, s, prop, ismath, rgb=(0,0,0)): @@ -229,7 +224,7 @@ Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb) m,n,tmp = Z.shape # TODO: descent of TeX text (I am imitating backend_ps here -JKS) - return n, m, m + return n, m, 0 if ismath: ox, oy, width, height, descent, fonts, used_characters = \ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007年09月04日 19:00:18 UTC (rev 3776) @@ -275,10 +275,9 @@ l,b,r,t = texmanager.get_ps_bbox(s, fontsize) w = (r-l) h = (t-b) - #print s, w, h # TODO: We need a way to get a good baseline from # text.usetex - return w, h, h + return w, h, 0 if ismath: width, height, descent, pswriter, used_characters = \ Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007年09月04日 19:00:18 UTC (rev 3776) @@ -541,7 +541,7 @@ self.font = font self.charmap = font.get_charmap() self.glyphmap = dict( - [(glyphind, ccode) for ccode, glyphind in self.charmap.items()]) + [(glyphind, ccode) for ccode, glyphind in self.charmap.iteritems()]) def __repr__(self): return repr(self.font) @@ -671,7 +671,7 @@ def __init__(self, *args, **kwargs): TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): - for key, val in self._fontmap.items(): + for key, val in self._fontmap.iteritems(): fullpath = os.path.join(self.basepath, val + ".ttf") self.fontmap[key] = fullpath self.fontmap[val] = fullpath Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/src/_backend_agg.cpp 2007年09月04日 19:00:18 UTC (rev 3776) @@ -16,6 +16,9 @@ #include "agg_scanline_storage_aa.h" #include "agg_scanline_storage_bin.h" #include "agg_renderer_primitives.h" +#include "agg_span_image_filter_gray.h" +#include "agg_span_interpolator_linear.h" +#include "agg_span_allocator.h" #include "util/agg_color_conv_rgb8.h" #include "ft2font.h" @@ -2103,13 +2106,74 @@ } +/** + * This is a custom span generator that converts spans in the + * 8-bit inverted greyscale font buffer to rgba that agg can use. + */ +template< + class ColorT, + class ChildGenerator> +class font_to_rgba : + public agg::span_generator<ColorT, + agg::span_allocator<ColorT> > +{ +public: + typedef ChildGenerator child_type; + typedef ColorT color_type; + typedef agg::span_allocator<color_type> allocator_type; + typedef agg::span_generator< + ColorT, + agg::span_allocator<ColorT> > base_type; +private: + child_type* _gen; + allocator_type _alloc; + color_type _color; + +public: + font_to_rgba(child_type* gen, color_type color) : + base_type(_alloc), + _gen(gen), + _color(color) { + } + color_type* generate(int x, int y, unsigned len) + { + color_type* dst = base_type::allocator().span(); + + typename child_type::color_type* src = _gen->generate(x, y, len); + + do { + *dst = _color; + dst->a = src->v; + ++src; + ++dst; + } while (--len); + + return base_type::allocator().span(); + } + + void prepare(unsigned max_span_len) + { + _alloc.allocate(max_span_len); + _gen->prepare(max_span_len); + } + +}; + Py::Object RendererAgg::draw_text_image(const Py::Tuple& args) { _VERBOSE("RendererAgg::draw_text"); + + typedef agg::span_interpolator_linear<> interpolator_type; + typedef agg::span_image_filter_gray<agg::gray8, interpolator_type> + image_span_gen_type; + typedef font_to_rgba<pixfmt::color_type, image_span_gen_type> + span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_gen_type> + renderer_type; - args.verify_length(4); + args.verify_length(5); FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); if (!image->get_buffer()) @@ -2125,70 +2189,48 @@ return Py::Object(); } - GCAgg gc = GCAgg(args[3], dpi); + double angle = Py::Float( args[3] ); + + GCAgg gc = GCAgg(args[4], dpi); - set_clipbox_rasterizer( gc.cliprect); - - - pixfmt::color_type p; - p.r = int(255*gc.color.r); - p.b = int(255*gc.color.b); - p.g = int(255*gc.color.g); - p.a = int(255*gc.color.a); - - //y = y-font->image.height; - unsigned thisx, thisy; - - double l = 0; - double b = 0; - double r = width; - double t = height; - if (gc.cliprect!=NULL) { - l = gc.cliprect[0] ; - b = gc.cliprect[1] ; - double w = gc.cliprect[2]; - double h = gc.cliprect[3]; - r = l+w; - t = b+h; - } - + set_clipbox_rasterizer(gc.cliprect); + const unsigned char* const buffer = image->get_buffer(); + agg::rendering_buffer srcbuf + ((agg::int8u*)buffer, image->get_width(), + image->get_height(), image->get_width()); + agg::pixfmt_gray8 pixf_img(srcbuf); - for (size_t i=0; i< image->get_width(); i++) { - for (size_t j=0; j< image->get_height(); j++) { - thisx = i+x+image->offsetx; - thisy = j+y+image->offsety; - if (thisx<l || thisx>=r) continue; - if (thisy<height-t || thisy>=height-b) continue; - pixFmt->blend_pixel - (thisx, thisy, p, buffer[i + j*image->get_width()]); - } - } + agg::trans_affine mtx; + mtx *= agg::trans_affine_translation(0, -(int)image->get_height()); + mtx *= agg::trans_affine_rotation(-angle * agg::pi / 180.0); + mtx *= agg::trans_affine_translation(x, y); + + agg::path_storage rect; + rect.move_to(0, 0); + rect.line_to(image->get_width(), 0); + rect.line_to(image->get_width(), image->get_height()); + rect.line_to(0, image->get_height()); + rect.line_to(0, 0); + agg::conv_transform<agg::path_storage> rect2(rect, mtx); + + agg::trans_affine inv_mtx(mtx); + inv_mtx.invert(); + + agg::image_filter_lut filter; + filter.calculate(agg::image_filter_spline36()); + interpolator_type interpolator(inv_mtx); + agg::span_allocator<agg::gray8> gray_span_allocator; + image_span_gen_type image_span_generator(gray_span_allocator, + srcbuf, 0, interpolator, filter); + span_gen_type output_span_generator(&image_span_generator, gc.color); + renderer_type ri(*rendererBase, output_span_generator); + agg::rasterizer_scanline_aa<> rasterizer; + agg::scanline_p8 scanline; + rasterizer.add_path(rect2); + agg::render_scanlines(rasterizer, scanline, ri); - /* bbox the text for debug purposes - - agg::path_storage path; - - path.move_to(x, y); - path.line_to(x, y+font->image.height); - path.line_to(x+font->image.width, y+font->image.height); - path.line_to(x+font->image.width, y); - path.close_polygon(); - - agg::rgba edgecolor(1,0,0,1); - - //now fill the edge - agg::conv_stroke<agg::path_storage> stroke(path); - stroke.width(1.0); - rendererAA->color(edgecolor); - //self->theRasterizer->gamma(agg::gamma_power(gamma)); - theRasterizer->add_path(stroke); - agg::render_scanlines(*theRasterizer, *slineP8, *rendererAA); - - */ - return Py::Object(); - } Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/src/ft2font.cpp 2007年09月04日 19:00:18 UTC (rev 3776) @@ -43,8 +43,6 @@ FT_Library _ft2Library; FT2Image::FT2Image() : - offsetx(0), offsety(0), - _bRotated(false), _isDirty(true), _buffer(NULL), _width(0), _height(0), @@ -54,8 +52,6 @@ } FT2Image::FT2Image(unsigned long width, unsigned long height) : - offsetx(0), offsety(0), - _bRotated(false), _isDirty(true), _buffer(NULL), _width(0), _height(0), @@ -85,7 +81,6 @@ for (size_t n=0; n<numBytes; n++) _buffer[n] = 0; - _bRotated = false; _isDirty = true; } @@ -113,10 +108,7 @@ _width = 0; _height = 0; - offsetx = 0; - offsety = 0; _isDirty = true; - _bRotated = false; delete [] _buffer; _buffer = NULL; if (_rgbCopy) { @@ -142,58 +134,6 @@ return Py::Object(); } -void FT2Image::rotate() { - // If we have already rotated, just return. - if (_bRotated) - return; - - unsigned long width = _width; - unsigned long height = _height; - - unsigned long newWidth = _height; - unsigned long newHeight = _width; - - unsigned long numBytes = _width * _height; - - unsigned char * buffer = new unsigned char [numBytes]; - - unsigned long i, j, k, offset, nhMinusOne; - - nhMinusOne = newHeight - 1; - - unsigned char * read_it = _buffer; - - for (i=0; i<height; i++) { - offset = i*width; - for (j=0; j<width; j++) { - k = nhMinusOne - j; - buffer[i + k*newWidth] = *(read_it++); - } - } - - delete [] _buffer; - _buffer = buffer; - _width = newWidth; - _height = newHeight; - _bRotated = true; - _isDirty = true; -} -char FT2Image::rotate__doc__[] = -"rotate()\n" -"\n" -"Rotates the image 90 degrees.\n" -; -Py::Object -FT2Image::py_rotate(const Py::Tuple & args) { - _VERBOSE("FT2Image::rotate"); - - args.verify_length(0); - - rotate(); - - return Py::Object(); -} - void FT2Image::draw_bitmap( FT_Bitmap* bitmap, FT_Int x, @@ -404,17 +344,11 @@ unsigned char *src_end = src + (_width * _height); unsigned char *dst = _rgbaCopy->_buffer; - // This pre-multiplies the alpha, which apparently shouldn't - // be necessary for wxGTK, but it sure as heck seems to be. - unsigned int c; - unsigned int tmp; while (src != src_end) { - c = *src++; - tmp = ((255 - c) * c) >> 8; - *dst++ = tmp; - *dst++ = tmp; - *dst++ = tmp; - *dst++ = c; + *dst++ = 0; + *dst++ = 0; + *dst++ = 0; + *dst++ = *src++; } } @@ -1266,12 +1200,6 @@ image->resize(width, height); } - image->offsetx = (int)(string_bbox.xMin / 64.0); - if (angle==0) - image->offsety = -image->get_height(); - else - image->offsety = (int)(-string_bbox.yMax/64.0); - for ( size_t n = 0; n < glyphs.size(); n++ ) { FT_BBox bbox; @@ -1840,8 +1768,6 @@ FT2Image::clear__doc__); add_varargs_method("resize", &FT2Image::py_resize, FT2Image::resize__doc__); - add_varargs_method("rotate", &FT2Image::py_rotate, - FT2Image::rotate__doc__); add_varargs_method("write_bitmap", &FT2Image::py_write_bitmap, FT2Image::write_bitmap__doc__); add_varargs_method("draw_rect", &FT2Image::py_draw_rect, Modified: trunk/matplotlib/src/ft2font.h =================================================================== --- trunk/matplotlib/src/ft2font.h 2007年09月04日 18:19:16 UTC (rev 3775) +++ trunk/matplotlib/src/ft2font.h 2007年09月04日 19:00:18 UTC (rev 3776) @@ -30,7 +30,6 @@ void resize(unsigned long width, unsigned long height); void clear(); - void rotate(); void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y); void write_bitmap(const char* filename) const; void draw_rect(unsigned long x0, unsigned long y0, @@ -46,8 +45,6 @@ Py::Object py_clear(const Py::Tuple & args); static char resize__doc__ []; Py::Object py_resize(const Py::Tuple & args); - static char rotate__doc__ []; - Py::Object py_rotate(const Py::Tuple & args); static char write_bitmap__doc__ []; Py::Object py_write_bitmap(const Py::Tuple & args); static char draw_rect__doc__ []; @@ -64,11 +61,7 @@ Py::Object py_get_width(const Py::Tuple & args); Py::Object py_get_height(const Py::Tuple & args); - unsigned long offsetx; - unsigned long offsety; - private: - bool _bRotated; bool _isDirty; unsigned char *_buffer; unsigned long _width; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3775 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3775&view=rev Author: jouni Date: 2007年09月04日 11:19:16 -0700 (2007年9月04日) Log Message: ----------- More work on supporting Type 1 fonts in PDF, still doesn't produce usable files. Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/lib/matplotlib/afm.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/dviread.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007年09月04日 14:52:03 UTC (rev 3774) +++ trunk/matplotlib/API_CHANGES 2007年09月04日 18:19:16 UTC (rev 3775) @@ -15,7 +15,8 @@ to read an afm file in addition to a pfa/pfb file, to get metrics and kerning information for a Type 1 font. - The AFM class now supports querying CapHeight and stem widths. + The AFM class now supports querying CapHeight and stem widths. The + get_name_char method now has an isord kwarg like get_width_char. Changed pcolor default to shading='flat'; but as noted now in the docstring, it is preferable to simply use the edgecolor kwarg. Modified: trunk/matplotlib/lib/matplotlib/afm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/afm.py 2007年09月04日 14:52:03 UTC (rev 3774) +++ trunk/matplotlib/lib/matplotlib/afm.py 2007年09月04日 18:19:16 UTC (rev 3775) @@ -378,11 +378,12 @@ """ return self.get_str_bbox_and_descent(s)[:4] - def get_name_char(self, c): + def get_name_char(self, c, isord=False): """ Get the name of the character, ie, ';' is 'semicolon' """ - wx, name, bbox = self._metrics[ord(c)] + if not isord: c=ord(c) + wx, name, bbox = self._metrics[c] return name def get_width_char(self, c, isord=False): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007年09月04日 14:52:03 UTC (rev 3774) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007年09月04日 18:19:16 UTC (rev 3775) @@ -18,6 +18,7 @@ from math import ceil, cos, floor, pi, sin from sets import Set +import matplotlib from matplotlib import __version__, rcParams, agg, get_data_path from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ @@ -493,12 +494,16 @@ def embedType1(self, filename, fontinfo): fh = open(filename, 'rb') + matplotlib.verbose.report( + 'Embedding Type 1 font ' + filename, 'debug') try: fontdata = fh.read() finally: fh.close() fh = open(fontinfo.afmfile, 'rb') + matplotlib.verbose.report( + 'Reading metrics from ' + fontinfo.afmfile, 'debug') try: afmdata = AFM(fh) finally: @@ -519,9 +524,26 @@ differencesArray = [ Name(ch) for ch in dviread.Encoding(fontinfo.encodingfile) ] differencesArray = [ 0 ] + differencesArray + firstchar = 0 lastchar = len(differencesArray) - 2 + widths = [ 100 for x in range(firstchar,lastchar+1) ] # XXX TODO else: - lastchar = 255 # ? + widths = [ None for i in range(256) ] + for ch in range(256): + try: + widths[ch] = afmdata.get_width_char(ch, isord=True) + except KeyError: + pass + not_None = (ch for ch in range(256) + if widths[ch] is not None) + firstchar = not_None.next() + lastchar = max(not_None) + widths = widths[firstchar:lastchar+1] + + differencesArray = [ firstchar ] + for ch in range(firstchar, lastchar+1): + differencesArray.append(Name( + afmdata.get_name_char(ch, isord=True))) fontdict = { 'Type': Name('Font'), @@ -533,16 +555,15 @@ 'FontDescriptor': fontdescObject, } - if fontinfo.encodingfile is not None: - fontdict.update({ - 'Encoding': { 'Type': Name('Encoding'), - 'Differences': differencesArray }, - }) + fontdict.update({ + 'Encoding': { 'Type': Name('Encoding'), + 'Differences': differencesArray }, + }) flags = 0 if fixed_pitch: flags |= 1 << 0 # fixed width if 0: flags |= 1 << 1 # TODO: serif - if 0: flags |= 1 << 2 # TODO: symbolic + if 1: flags |= 1 << 2 # TODO: symbolic else: flags |= 1 << 5 # non-symbolic if italic_angle: flags |= 1 << 6 # italic if 0: flags |= 1 << 16 # TODO: all caps @@ -557,12 +578,16 @@ 'ItalicAngle': italic_angle, 'Ascent': font.ascender, 'Descent': font.descender, - 'CapHeight': afmdata.get_capheight(), + 'CapHeight': 1000, # default guess if missing from AFM file 'XHeight': afmdata.get_xheight(), 'FontFile': fontfileObject, 'FontFamily': Name(familyname), #'FontWeight': a number where 400 = Regular, 700 = Bold } + try: + descriptor['CapHeight'] = afmdata.get_capheight() + except KeyError: + pass # StemV is obligatory in PDF font descriptors but optional in # AFM files. The collection of AFM files in my TeX Live 2007 @@ -579,7 +604,7 @@ descriptor['StemH'] = StemH self.writeObject(fontdictObject, fontdict) - self.writeObject(widthsObject, [ 100 for i in range(256)]) # XXX TODO + self.writeObject(widthsObject, widths) self.writeObject(fontdescObject, descriptor) fontdata = type1font.Type1Font(filename) @@ -591,6 +616,8 @@ self.currentstream.write(fontdata.data) self.endStream() + return fontdictObject + def _get_xobject_symbol_name(self, filename, symbol_name): return "%s-%s" % ( os.path.splitext(os.path.basename(filename))[0], Modified: trunk/matplotlib/lib/matplotlib/dviread.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dviread.py 2007年09月04日 14:52:03 UTC (rev 3774) +++ trunk/matplotlib/lib/matplotlib/dviread.py 2007年09月04日 18:19:16 UTC (rev 3775) @@ -35,6 +35,7 @@ opens the file; actually reading the file happens when iterating through the pages of the file. """ + matplotlib.verbose.report('Dvi: ' + filename, 'debug') self.file = open(filename, 'rb') self.dpi = dpi self.fonts = {} @@ -57,7 +58,7 @@ while True: have_page = self._read() if have_page: - yield self.text, self.boxes + yield self._output() else: break This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3774 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3774&view=rev Author: jdh2358 Date: 2007年09月04日 07:52:03 -0700 (2007年9月04日) Log Message: ----------- added manuels star poly patch Modified Paths: -------------- trunk/matplotlib/examples/scatter_star_poly.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc trunk/matplotlib/lib/matplotlib/pylab.py trunk/matplotlib/mpl1/mpl1.py Modified: trunk/matplotlib/examples/scatter_star_poly.py =================================================================== --- trunk/matplotlib/examples/scatter_star_poly.py 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/examples/scatter_star_poly.py 2007年09月04日 14:52:03 UTC (rev 3774) @@ -3,19 +3,25 @@ x = pylab.nx.mlab.rand(10) y = pylab.nx.mlab.rand(10) -pylab.subplot(221) +pylab.subplot(321) pylab.scatter(x,y,s=80,marker=">") -pylab.subplot(222) +pylab.subplot(322) pylab.scatter(x,y,s=80,marker=(5,0)) verts = zip([-1.,1.,1.],[-1.,-1.,1.]) -pylab.subplot(223) +pylab.subplot(323) pylab.scatter(x,y,s=80,marker=(verts,0)) # equivalent: #pylab.scatter(x,y,s=80,marker=None, verts=verts) -pylab.subplot(224) +pylab.subplot(324) pylab.scatter(x,y,s=80,marker=(5,1)) +pylab.subplot(325) +pylab.scatter(x,y,s=80,marker='+') + +pylab.subplot(326) +pylab.scatter(x,y,s=80,marker=(5,2), edgecolor='g') + pylab.show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007年09月04日 14:52:03 UTC (rev 3774) @@ -3976,16 +3976,18 @@ if not self._hold: self.cla() syms = { # a dict from symbol to (numsides, angle) - 's' : (4, math.pi/4.0), # square - 'o' : (20, 0), # circle - '^' : (3,0), # triangle up - '>' : (3,math.pi/2.0), # triangle right - 'v' : (3,math.pi), # triangle down - '<' : (3,3*math.pi/2.0), # triangle left - 'd' : (4,0), # diamond - 'p' : (5,0), # pentagram - 'h' : (6,0), # hexagon - '8' : (8,0), # octagon + 's' : (4,math.pi/4.0,0), # square + 'o' : (20,0,0), # circle + '^' : (3,0,0), # triangle up + '>' : (3,math.pi/2.0,0), # triangle right + 'v' : (3,math.pi,0), # triangle down + '<' : (3,3*math.pi/2.0,0), # triangle left + 'd' : (4,0,0), # diamond + 'p' : (5,0,0), # pentagram + 'h' : (6,0,0), # hexagon + '8' : (8,0,0), # octagon + '+' : (4,0,2), # plus + 'x' : (4,math.pi/4.0,2) # cross } self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) @@ -4013,7 +4015,7 @@ else: edgecolors = 'None' sym = None - starlike = False + symstyle = 0 # to be API compatible if marker is None and not (verts is None): @@ -4025,7 +4027,7 @@ sym = syms.get(marker) if sym is None and verts is None: raise ValueError('Unknown marker symbol to scatter') - numsides, rotation = syms[marker] + numsides, rotation, symstyle = syms[marker] elif iterable(marker): # accept marker to be: @@ -4040,21 +4042,19 @@ # (numsides, style, [angle]) if len(marker)==2: - numsides, rotation = marker[0], math.pi/4. + numsides, rotation = marker[0], 0. elif len(marker)==3: numsides, rotation = marker[0], marker[2] sym = True - if marker[1]==1: - # starlike symbol, everthing else is interpreted - # as solid symbol - starlike = True + if marker[1] in (1,2): + symstyle = marker[1] else: verts = npy.asarray(marker[0]) if sym is not None: - if not starlike: + if symstyle==0: collection = mcoll.RegularPolyCollection( self.figure.dpi, @@ -4065,7 +4065,7 @@ offsets = zip(x,y), transOffset = self.transData, ) - else: + elif symstyle==1: collection = mcoll.StarPolygonCollection( self.figure.dpi, numsides, rotation, scales, @@ -4075,6 +4075,16 @@ offsets = zip(x,y), transOffset = self.transData, ) + elif symstyle==2: + collection = mcoll.AsteriskPolygonCollection( + self.figure.dpi, + numsides, rotation, scales, + facecolors = colors, + edgecolors = edgecolors, + linewidths = linewidths, + offsets = zip(x,y), + transOffset = self.transData, + ) else: # rescale verts rescale = npy.sqrt(max(verts[:,0]**2+verts[:,1]**2)) Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/lib/matplotlib/collections.py 2007年09月04日 14:52:03 UTC (rev 3774) @@ -568,9 +568,42 @@ ns2 = self.numsides*2 r = scale*npy.ones(ns2) r[1::2] *= 0.5 - theta = (2.*math.pi/(ns2))*npy.arange(ns2) + self.rotation + theta = (math.pi/self.numsides)*npy.arange(ns2) + self.rotation self._verts = zip( r*npy.sin(theta), r*npy.cos(theta) ) +class AsteriskPolygonCollection(RegularPolyCollection): + def __init__(self, + dpi, + numsides, + rotation = 0 , + sizes = (1,), + **kwargs): + """ + Draw a regular asterisk Polygone with numsides spikes. + + * dpi is the figure dpi instance, and is required to do the + area scaling. + + * numsides: the number of spikes of the polygon + + * sizes gives the area of the circle circumscribing the + regular polygon in points^2 + + * rotation is the rotation of the polygon in radians + + %(PatchCollection)s + """ + + RegularPolyCollection.__init__(self, dpi, numsides, rotation, sizes, **kwargs) + __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd + + def _update_verts(self): + scale = 1.0/math.sqrt(math.pi) + r = scale*npy.ones(self.numsides*2) + r[1::2] = 0 + theta = (math.pi/self.numsides)*npy.arange(2*self.numsides) + self.rotation + self._verts = zip( r*npy.sin(theta), r*npy.cos(theta) ) + class LineCollection(Collection, cm.ScalarMappable): """ All parameters must be sequences or scalars; if scalars, they will Modified: trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc =================================================================== --- trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc 2007年09月04日 14:52:03 UTC (rev 3774) @@ -26,7 +26,7 @@ #### CONFIGURATION BEGINS HERE # the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg # Agg Cairo GD GDK Paint PS PDF SVG Template -backend : WXAgg +backend : TkAgg numerix : numpy # numpy, Numeric or numarray #maskedarray : False # True to use external maskedarray module # instead of numpy.ma; this is a temporary Modified: trunk/matplotlib/lib/matplotlib/pylab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pylab.py 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/lib/matplotlib/pylab.py 2007年09月04日 14:52:03 UTC (rev 3774) @@ -1464,8 +1464,8 @@ is either an int or a string. if it is an int, it indicates the column number. If it is a string, it indicates the column header. mpl will make column headers lower case, replace spaces with - strings, and remove all illegal characters; so 'Adj Close*' will - have name 'adj_close' + underscores, and remove all illegal characters; so 'Adj Close*' + will have name 'adj_close' if len(cols)==1, only that column will be plotted on the y axis. if len(cols)>1, the first element will be an identifier for data @@ -1480,7 +1480,8 @@ names in both. comments, skiprows, checkrows, and delimiter are all passed on to - matplotlib.mlab.csv2rec to load the data into a record array + matplotlib.mlab.csv2rec to load the data into a record array. See + the help there fore more information. kwargs are passed on to plotting functions Modified: trunk/matplotlib/mpl1/mpl1.py =================================================================== --- trunk/matplotlib/mpl1/mpl1.py 2007年09月04日 05:58:48 UTC (rev 3773) +++ trunk/matplotlib/mpl1/mpl1.py 2007年09月04日 14:52:03 UTC (rev 3774) @@ -12,7 +12,7 @@ sudo rm -rf /usr/local/lib/python2.5/site-packages/enthought* sudo easy_install \ -f http://code.enthought.com/enstaller/eggs/source/unstable \ - "enthought.resource <3.0a" "enthought.traits < 3.0a" + "enthought.traits < 3.0a" """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3773 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3773&view=rev Author: efiring Date: 2007年09月03日 22:58:48 -0700 (2007年9月03日) Log Message: ----------- Update CHANGELOG and API_CHANGES for Manuel Metz's errorbar patch. Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007年09月04日 05:53:56 UTC (rev 3772) +++ trunk/matplotlib/API_CHANGES 2007年09月04日 05:58:48 UTC (rev 3773) @@ -1,3 +1,7 @@ + The errorbar method and function now accept additional kwargs + so that upper and lower limits can be indicated by capping the + bar with a caret instead of a straight line segment. + The dviread.py file now has a parser for files like psfonts.map and pdftex.map, to map TeX font names to external files. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007年09月04日 05:53:56 UTC (rev 3772) +++ trunk/matplotlib/CHANGELOG 2007年09月04日 05:58:48 UTC (rev 3773) @@ -1,3 +1,6 @@ +2007年09月03日 Added ability of errorbar show limits via caret or + arrowhead ends on the bars; patch by Manual Metz. - EF + 2007年09月03日 Created type1font.py, added features to AFM and FT2Font (see API_CHANGES), started work on embedding Type 1 fonts in pdf files. - JKS @@ -7,7 +10,7 @@ 2007年08月16日 Added a set_extent method to AxesImage, allow data extent to be modified after initial call to imshow - DSD -2007年08月14日 Fixed a bug in pyqt4 subplots-adjust. Thanks to +2007年08月14日 Fixed a bug in pyqt4 subplots-adjust. Thanks to Xavier Gnata for the report and suggested fix - DSD 2007年08月13日 Use pickle to cache entire fontManager; change to using This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3772 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3772&view=rev Author: efiring Date: 2007年09月03日 22:53:56 -0700 (2007年9月03日) Log Message: ----------- Errorbar limit symbols patch by Manuel Metz Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/lines.py Added Paths: ----------- trunk/matplotlib/examples/errorbar_limits.py Added: trunk/matplotlib/examples/errorbar_limits.py =================================================================== --- trunk/matplotlib/examples/errorbar_limits.py (rev 0) +++ trunk/matplotlib/examples/errorbar_limits.py 2007年09月04日 05:53:56 UTC (rev 3772) @@ -0,0 +1,40 @@ +''' +Illustration of upper and lower limit symbols on errorbars +''' + +from math import pi +from numpy import array, arange, sin +import pylab as P + +fig = P.figure() +x = arange(10.0) +y = sin(arange(10.0)/20.0*pi) + +P.errorbar(x,y,yerr=0.1,capsize=3) + +y = sin(arange(10.0)/20.0*pi) + 1 +P.errorbar(x,y,yerr=0.1, uplims=True) + +y = sin(arange(10.0)/20.0*pi) + 2 +upperlimits = array([1,0]*5) +lowerlimits = array([0,1]*5) +P.errorbar(x, y, yerr=0.1, uplims=upperlimits, lolims=lowerlimits) + +P.xlim(-1,10) + +fig = P.figure() +x = arange(10.0)/10.0 +y = (x+0.1)**2 + +P.errorbar(x, y, xerr=0.1, xlolims=True) +y = (x+0.1)**3 + +P.errorbar(x+0.6, y, xerr=0.1, xuplims=upperlimits, xlolims=lowerlimits) + +y = (x+0.1)**4 +P.errorbar(x+1.2, y, xerr=0.1, xuplims=True) + +P.xlim(-0.2,2.4) +P.ylim(-0.1,1.3) + +P.show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007年09月03日 22:16:19 UTC (rev 3771) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007年09月04日 05:53:56 UTC (rev 3772) @@ -3522,10 +3522,13 @@ def errorbar(self, x, y, yerr=None, xerr=None, fmt='-', ecolor=None, capsize=3, - barsabove=False, **kwargs): + barsabove=False, lolims=False, uplims=False, + xlolims=False, xuplims=False, **kwargs): """ ERRORBAR(x, y, yerr=None, xerr=None, - fmt='b-', ecolor=None, capsize=3, barsabove=False) + fmt='b-', ecolor=None, capsize=3, barsabove=False, + lolims=False, uplims=False, + xlolims=False, xuplims=False) Plot x versus y with error deltas in yerr and xerr. Vertical errorbars are plotted if yerr is not None @@ -3554,6 +3557,11 @@ barsabove, if True, will plot the errorbars above the plot symbols - default is below + lolims, uplims, xlolims, xuplims: These arguments can be used + to indicate that a value gives only upper/lower limits. In + that case a caret symbol is used to indicate this. lims-arguments + may be of the same type as xerr and yerr. + kwargs are passed on to the plot command for the markers. So you can add additional key=value pairs to control the errorbar markers. For example, this code makes big red @@ -3579,18 +3587,18 @@ if not self._hold: self.cla() # make sure all the args are iterable arrays - if not iterable(x): x = npy.asarray([x]) + if not iterable(x): x = npy.array([x]) else: x = npy.asarray(x) - if not iterable(y): y = npy.asarray([y]) + if not iterable(y): y = npy.array([y]) else: y = npy.asarray(y) if xerr is not None: - if not iterable(xerr): xerr = npy.asarray([xerr]) + if not iterable(xerr): xerr = npy.array([xerr]) else: xerr = npy.asarray(xerr) if yerr is not None: - if not iterable(yerr): yerr = npy.asarray([yerr]) + if not iterable(yerr): yerr = npy.array([yerr]) else: yerr = npy.asarray(yerr) l0 = None @@ -3607,6 +3615,18 @@ if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] + if not iterable(lolims): lolims = npy.array([lolims]*len(x), bool) + else: lolims = npy.asarray(lolims, bool) + + if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) + else: uplims = npy.asarray(uplims, bool) + + if not iterable(xlolims): xlolims = npy.array([xlolims]*len(x), bool) + else: xlolims = npy.asarray(xlolims, bool) + + if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool) + else: xuplims = npy.asarray(xuplims, bool) + if capsize > 0: plot_kw = { 'ms':2*capsize, @@ -3626,9 +3646,20 @@ barcols.append( self.hlines(y, left, right, **lines_kw ) ) if capsize > 0: - caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) - caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) + if xlolims.any(): + caplines.extend( self.plot(left[xlolims], y[xlolims], ls='None', marker=mlines.CARETLEFT, **plot_kw) ) + xlolims = ~xlolims + caplines.extend( self.plot(left[xlolims], y[xlolims], 'k|', **plot_kw) ) + else: + caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) + if xuplims.any(): + caplines.extend( self.plot(right[xuplims], y[xuplims], ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) + xuplims = ~xuplims + caplines.extend( self.plot(right[xuplims], y[xuplims], 'k|', **plot_kw) ) + else: + caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) + if yerr is not None: if len(yerr.shape) == 1: lower = y-yerr @@ -3639,9 +3670,21 @@ barcols.append( self.vlines(x, lower, upper, **lines_kw) ) if capsize > 0: - caplines.extend( self.plot(x, lower, 'k_', **plot_kw) ) - caplines.extend( self.plot(x, upper, 'k_', **plot_kw) ) + if lolims.any(): + caplines.extend( self.plot(x[lolims], lower[lolims], ls='None', marker=mlines.CARETDOWN, **plot_kw) ) + lolims = ~lolims + caplines.extend( self.plot(x[lolims], lower[lolims], 'k_', **plot_kw) ) + else: + caplines.extend( self.plot(x, lower, 'k_', **plot_kw) ) + + if uplims.any(): + caplines.extend( self.plot(x[uplims], upper[uplims], ls='None', marker=mlines.CARETUP, **plot_kw) ) + uplims = ~uplims + caplines.extend( self.plot(x[uplims], upper[uplims], 'k_', **plot_kw) ) + else: + caplines.extend( self.plot(x, upper, 'k_', **plot_kw) ) + if not barsabove and fmt is not None: l0, = self.plot(x,y,fmt,**kwargs) Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2007年09月03日 22:16:19 UTC (rev 3771) +++ trunk/matplotlib/lib/matplotlib/lines.py 2007年09月04日 05:53:56 UTC (rev 3772) @@ -21,7 +21,9 @@ from transforms import lbwh_to_bbox, LOG10 from matplotlib import rcParams -TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN = range(4) +# special-purpose marker identifiers: +(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN, + CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8) def unmasked_index_ranges(mask, compressed = True): ''' @@ -97,7 +99,7 @@ point_hits = (cx - x)**2 + (cy - y)**2 <= radius**2 #if any(point_hits): print "points",xr[candidates] candidates = candidates & ~point_hits[:-1] & ~point_hits[1:] - + # For those candidates which remain, determine how far they lie away # from the line. px,py = xr+u*dx,yr+u*dy @@ -147,6 +149,10 @@ TICKRIGHT : '_draw_tickright', TICKUP : '_draw_tickup', TICKDOWN : '_draw_tickdown', + CARETLEFT : '_draw_caretleft', + CARETRIGHT : '_draw_caretright', + CARETUP : '_draw_caretup', + CARETDOWN : '_draw_caretdown', 'None' : '_draw_nothing', ' ' : '_draw_nothing', '' : '_draw_nothing', @@ -1201,6 +1207,62 @@ renderer.draw_line(gc, x, y, x-offset2, y+offset1) renderer.draw_line(gc, x, y, x-offset2, y-offset1) + def _draw_caretdown(self, renderer, gc, xt, yt): + offset = 0.5*renderer.points_to_pixels(self._markersize) + offset1 = 1.5*offset + if self._newstyle: + path = agg.path_storage() + path.move_to(-offset, offset1) + path.line_to(0, 0) + path.line_to(+offset, offset1) + renderer.draw_markers(gc, path, None, xt, yt, self.get_transform()) + else: + for (x,y) in zip(xt, yt): + renderer.draw_line(gc, x-offset, y+offset1, x, y) + renderer.draw_line(gc, x, y, x+offset, y+offset1) + + def _draw_caretup(self, renderer, gc, xt, yt): + offset = 0.5*renderer.points_to_pixels(self._markersize) + offset1 = 1.5*offset + if self._newstyle: + path = agg.path_storage() + path.move_to(-offset, -offset1) + path.line_to(0, 0) + path.line_to(+offset, -offset1) + renderer.draw_markers(gc, path, None, xt, yt, self.get_transform()) + else: + for (x,y) in zip(xt, yt): + renderer.draw_line(gc, x-offset, y-offset1, x, y) + renderer.draw_line(gc, x, y, x+offset, y-offset1) + + def _draw_caretleft(self, renderer, gc, xt, yt): + offset = 0.5*renderer.points_to_pixels(self._markersize) + offset1 = 1.5*offset + if self._newstyle: + path = agg.path_storage() + path.move_to(offset1, -offset) + path.line_to(0, 0) + path.line_to(offset1, offset) + renderer.draw_markers(gc, path, None, xt, yt, self.get_transform()) + else: + for (x,y) in zip(xt, yt): + renderer.draw_line(gc, x+offset1, y-offset, x, y) + renderer.draw_line(gc, x, y, x+offset1, y+offset) + + def _draw_caretright(self, renderer, gc, xt, yt): + offset = 0.5*renderer.points_to_pixels(self._markersize) + offset1 = 1.5*offset + if self._newstyle: + path = agg.path_storage() + path.move_to(-offset1, -offset) + path.line_to(0, 0) + path.line_to(-offset1, offset) + renderer.draw_markers(gc, path, None, xt, yt, self.get_transform()) + else: + for (x,y) in zip(xt, yt): + renderer.draw_line(gc, x-offset1, y-offset, x, y) + renderer.draw_line(gc, x, y, x-offset1, y+offset) + def _draw_x(self, renderer, gc, xt, yt): offset = 0.5*renderer.points_to_pixels(self._markersize) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.