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) |
2
|
3
(1) |
4
|
5
|
6
(1) |
7
(1) |
8
(1) |
9
|
10
(2) |
11
(5) |
12
(1) |
13
|
14
(4) |
15
|
16
(2) |
17
(5) |
18
(1) |
19
(3) |
20
(2) |
21
(5) |
22
(6) |
23
(6) |
24
(1) |
25
|
26
(2) |
27
(5) |
28
(3) |
29
(4) |
30
(3) |
31
(17) |
|
Revision: 7327 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7327&view=rev Author: jdh2358 Date: 2009年07月31日 18:55:17 +0000 (2009年7月31日) Log Message: ----------- added lena to mpl_data Added Paths: ----------- trunk/mpl_data/ trunk/mpl_data/lena.png Added: trunk/mpl_data/lena.png =================================================================== (Binary files differ) Property changes on: trunk/mpl_data/lena.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7326 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7326&view=rev Author: jdh2358 Date: 2009年07月31日 18:11:50 +0000 (2009年7月31日) Log Message: ----------- update the makefile for win32 build Modified Paths: -------------- branches/v0_99_maint/release/win32/Makefile Modified: branches/v0_99_maint/release/win32/Makefile =================================================================== --- branches/v0_99_maint/release/win32/Makefile 2009年07月31日 15:52:19 UTC (rev 7325) +++ branches/v0_99_maint/release/win32/Makefile 2009年07月31日 18:11:50 UTC (rev 7326) @@ -1,4 +1,4 @@ -PYDIR = C:/Python26 +PYDIR = C:/Python25 PYTHON = ${PYDIR}/python.exe SRCDIR = ${PWD} WINSRCDIR = `${PWD}/data/mingw_path.sh ${PWD}` @@ -6,7 +6,7 @@ PNGVERSION = 1.2.36 FREETYPEVERSION = 2.3.9 TCLTKVERSION = 8.5.7 -MPLVERSION = 0.98.5.3 +MPLVERSION = 0.99.0.rc1 ## You shouldn't need to configure past this point @@ -89,8 +89,8 @@ rm -rf build &&\ cp ../data/setup*.* . &&\ export CFLAGS="${CFLAGS}" &&\ - ${PYTHON} setupwin.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_wininst - #${PYTHON} setupwinegg.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_egg + ${PYTHON} setupwin.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_wininst &&\ + ${PYTHON} setupwinegg.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_egg inplace: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7325 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7325&view=rev Author: jdh2358 Date: 2009年07月31日 15:52:19 +0000 (2009年7月31日) Log Message: ----------- added miktex win32 patch from sf patch 2820194 Modified Paths: -------------- branches/v0_99_maint/lib/matplotlib/texmanager.py branches/v0_99_maint/setupext.py Modified: branches/v0_99_maint/lib/matplotlib/texmanager.py =================================================================== --- branches/v0_99_maint/lib/matplotlib/texmanager.py 2009年07月31日 15:39:30 UTC (rev 7324) +++ branches/v0_99_maint/lib/matplotlib/texmanager.py 2009年07月31日 15:52:19 UTC (rev 7325) @@ -56,7 +56,7 @@ def dvipng_hack_alpha(): p = Popen('dvipng -version', shell=True, stdin=PIPE, stdout=PIPE, - stderr=STDOUT, close_fds=True) + stderr=STDOUT, close_fds=(sys.platform!='win32')) stdin, stdout = p.stdin, p.stdout for line in stdout: if line.startswith('dvipng '): Modified: branches/v0_99_maint/setupext.py =================================================================== --- branches/v0_99_maint/setupext.py 2009年07月31日 15:39:30 UTC (rev 7324) +++ branches/v0_99_maint/setupext.py 2009年07月31日 15:52:19 UTC (rev 7325) @@ -174,7 +174,7 @@ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - close_fds=True) + close_fds=(sys.platform != 'win32')) return p.stdin, p.stdout class CleanUpFile: @@ -458,7 +458,7 @@ try: stdin, stdout = run_child_process('latex -version') line = stdout.readlines()[0] - pattern = '3\.1\d+' + pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)' match = re.search(pattern, line) print_status("latex", match.group(0)) return True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7324 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7324&view=rev Author: jdh2358 Date: 2009年07月31日 15:39:30 +0000 (2009年7月31日) Log Message: ----------- revert setupext.py patch for osx; breaks my osx test build Modified Paths: -------------- branches/v0_99_maint/setupext.py Modified: branches/v0_99_maint/setupext.py =================================================================== --- branches/v0_99_maint/setupext.py 2009年07月31日 15:32:11 UTC (rev 7323) +++ branches/v0_99_maint/setupext.py 2009年07月31日 15:39:30 UTC (rev 7324) @@ -51,7 +51,7 @@ 'linux' : ['/usr/local', '/usr',], 'cygwin' : ['/usr/local', '/usr',], 'darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local', - '/usr', '/sw'], + '/usr', '/sw', '/usr/X11R6'], 'freebsd4' : ['/usr/local', '/usr'], 'freebsd5' : ['/usr/local', '/usr'], 'freebsd6' : ['/usr/local', '/usr'], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7323 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7323&view=rev Author: jdh2358 Date: 2009年07月31日 15:32:11 +0000 (2009年7月31日) Log Message: ----------- apply sf patches 2830233 and 2823885 for osx setup and 64 bit; thanks Michiel Modified Paths: -------------- branches/v0_99_maint/release/osx/Makefile branches/v0_99_maint/setupext.py branches/v0_99_maint/src/_macosx.m Modified: branches/v0_99_maint/release/osx/Makefile =================================================================== --- branches/v0_99_maint/release/osx/Makefile 2009年07月31日 13:49:33 UTC (rev 7322) +++ branches/v0_99_maint/release/osx/Makefile 2009年07月31日 15:32:11 UTC (rev 7323) @@ -2,7 +2,7 @@ ZLIBVERSION=1.2.3 PNGVERSION=1.2.33 FREETYPEVERSION=2.3.7 -MPLVERSION=0.98.5.3 +MPLVERSION=0.99.0.rc1 MPLSRC=matplotlib-${MPLVERSION} MACOSX_DEPLOYMENT_TARGET=10.4 Modified: branches/v0_99_maint/setupext.py =================================================================== --- branches/v0_99_maint/setupext.py 2009年07月31日 13:49:33 UTC (rev 7322) +++ branches/v0_99_maint/setupext.py 2009年07月31日 15:32:11 UTC (rev 7323) @@ -51,7 +51,7 @@ 'linux' : ['/usr/local', '/usr',], 'cygwin' : ['/usr/local', '/usr',], 'darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local', - '/usr', '/sw', '/usr/X11R6'], + '/usr', '/sw'], 'freebsd4' : ['/usr/local', '/usr'], 'freebsd5' : ['/usr/local', '/usr'], 'freebsd6' : ['/usr/local', '/usr'], Modified: branches/v0_99_maint/src/_macosx.m =================================================================== --- branches/v0_99_maint/src/_macosx.m 2009年07月31日 13:49:33 UTC (rev 7322) +++ branches/v0_99_maint/src/_macosx.m 2009年07月31日 15:32:11 UTC (rev 7323) @@ -7,15 +7,19 @@ static int nwin = 0; /* The number of open windows */ + +/* Use Atsui for Mac OS X 10.4, CoreText for Mac OS X 10.5 */ +#ifndef MAC_OS_X_VERSION_10_5 static int ngc = 0; /* The number of graphics contexts in use */ /* For drawing Unicode strings with ATSUI */ static ATSUStyle style = NULL; static ATSUTextLayout layout = NULL; +#endif /* CGFloat was defined in Mac OS X 10.5 */ -#ifndef CGFloat +#ifndef CGFLOAT_DEFINED #define CGFloat float #endif @@ -171,6 +175,7 @@ return 1; } +#ifndef MAC_OS_X_VERSION_10_5 static int _init_atsui(void) { OSStatus status; @@ -208,6 +213,7 @@ if (status!=noErr) PyErr_WarnEx(PyExc_RuntimeWarning, "ATSUDisposeTextLayout failed", 1); } +#endif static int _draw_path(CGContextRef cr, void* iterator) { @@ -336,6 +342,10 @@ - (void)mouseUp:(NSEvent*)event; - (void)mouseDragged:(NSEvent*)event; - (void)mouseMoved:(NSEvent*)event; +- (void)rightMouseDown:(NSEvent*)event; +- (void)rightMouseUp:(NSEvent*)event; +- (void)otherMouseDown:(NSEvent*)event; +- (void)otherMouseUp:(NSEvent*)event; - (void)setRubberband:(NSRect)rect; - (void)removeRubberband; - (const char*)convertKeyEvent:(NSEvent*)event; @@ -375,6 +385,7 @@ CGContextRef cr; NSSize size; int level; + CGFloat color[4]; } GraphicsContext; static CGMutablePathRef _create_path(void* iterator) @@ -440,6 +451,7 @@ self->cr = NULL; self->level = 0; +#ifndef MAC_OS_X_VERSION_10_5 if (ngc==0) { int ok = _init_atsui(); @@ -449,10 +461,12 @@ } } ngc++; +#endif return (PyObject*) self; } +#ifndef MAC_OS_X_VERSION_10_5 static void GraphicsContext_dealloc(GraphicsContext *self) { @@ -461,6 +475,7 @@ self->ob_type->tp_free((PyObject*)self); } +#endif static PyObject* GraphicsContext_repr(GraphicsContext* self) @@ -516,6 +531,9 @@ return NULL; } CGContextSetAlpha(cr, alpha); + + self->color[3] = alpha; + Py_INCREF(Py_None); return Py_None; } @@ -651,7 +669,7 @@ static BOOL _set_dashes(CGContextRef cr, PyObject* linestyle) { - float phase = 0.0; + CGFloat phase = 0.0; PyObject* offset; PyObject* dashes; @@ -686,7 +704,7 @@ } int n = PyTuple_GET_SIZE(dashes); int i; - float* lengths = malloc(n*sizeof(float)); + CGFloat* lengths = malloc(n*sizeof(CGFloat)); if(!lengths) { PyErr_SetString(PyExc_MemoryError, "Failed to store dashes"); @@ -697,9 +715,9 @@ { PyObject* value = PyTuple_GET_ITEM(dashes, i); if (PyFloat_Check(value)) - lengths[i] = (float) PyFloat_AS_DOUBLE(value); + lengths[i] = (CGFloat) PyFloat_AS_DOUBLE(value); else if (PyInt_Check(value)) - lengths[i] = (float) PyInt_AS_LONG(value); + lengths[i] = (CGFloat) PyInt_AS_LONG(value); else break; } Py_DECREF(dashes); @@ -750,6 +768,11 @@ CGContextSetRGBStrokeColor(cr, r, g, b, 1.0); CGContextSetRGBFillColor(cr, r, g, b, 1.0); + + self->color[0] = r; + self->color[1] = g; + self->color[2] = b; + Py_INCREF(Py_None); return Py_None; } @@ -889,28 +912,12 @@ } else { - int ok; - float color[4] = {0, 0, 0, 1}; CGPatternRef pattern; CGColorSpaceRef baseSpace; CGColorSpaceRef patternSpace; static const CGPatternCallbacks callbacks = {0, &_draw_hatch, &_release_hatch}; - PyObject* rgb = PyObject_CallMethod((PyObject*)self, "get_rgb", ""); - if (!rgb) - { - Py_DECREF(hatchpath); - return NULL; - } - ok = PyArg_ParseTuple(rgb, "ffff", &color[0], &color[1], &color[2], &color[3]); - Py_DECREF(rgb); - if (!ok) - { - Py_DECREF(hatchpath); - return NULL; - } - baseSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); if (!baseSpace) { @@ -938,7 +945,7 @@ kCGPatternTilingNoDistortion, false, &callbacks); - CGContextSetFillPattern(cr, pattern, color); + CGContextSetFillPattern(cr, pattern, self->color); CGPatternRelease(pattern); iterator = get_path_iterator(path, transform, @@ -1227,6 +1234,8 @@ if (Ntransforms) { + CGAffineTransform master; + double a, b, c, d, tx, ty; PyObject* values = PyObject_CallMethod(master_transform, "to_values", ""); if (!values) { @@ -1239,15 +1248,15 @@ ok = 0; goto exit; } - CGAffineTransform master; - ok = PyArg_ParseTuple(values, "ffffff", - &master.a, - &master.b, - &master.c, - &master.d, - &master.tx, - &master.ty); + /* CGAffineTransform contains CGFloat; cannot use master directly */ + ok = PyArg_ParseTuple(values, "dddddd", &a, &b, &c, &d, &tx, &ty); Py_DECREF(values); + master.a = a; + master.b = b; + master.c = c; + master.d = d; + master.tx = tx; + master.ty = ty; if (!ok) goto exit; CGContextConcatCTM(cr, master); } @@ -1652,13 +1661,15 @@ } if (PyTuple_Check(values)) { - ok = PyArg_ParseTuple(values, "ffffff", - &master.a, - &master.b, - &master.c, - &master.d, - &master.tx, - &master.ty); + double a, b, c, d, tx, ty; + /* CGAffineTransform contains CGFloat; cannot use master directly */ + ok = PyArg_ParseTuple(values, "dddddd", &a, &b, &c, &d, &tx, &ty); + master.a = a; + master.b = b; + master.c = c; + master.d = d; + master.tx = tx; + master.ty = ty; } else { @@ -1866,7 +1877,11 @@ } +#ifdef MAC_OS_X_VERSION_10_5 +static CTFontRef +#else static ATSFontRef +#endif setfont(CGContextRef cr, PyObject* family, float size, const char weight[], const char italic[]) { @@ -1876,7 +1891,11 @@ const char* temp; const char* name = "Times-Roman"; CFStringRef string; - ATSFontRef atsfont = 0; +#ifdef MAC_OS_X_VERSION_10_5 + CTFontRef font = 0; +#else + ATSFontRef font = 0; +#endif const int k = (strcmp(italic, "italic") ? 0 : 2) + (strcmp(weight, "bold") ? 0 : 1); @@ -2072,26 +2091,38 @@ string = CFStringCreateWithCString(kCFAllocatorDefault, temp, kCFStringEncodingMacRoman); - atsfont = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault); +#ifdef MAC_OS_X_VERSION_10_5 + font = CTFontCreateWithName(string, size, NULL); +#else + font = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault); +#endif + CFRelease(string); - if(atsfont) + if(font) { name = temp; break; } } - if(!atsfont) + if(!font) { string = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingMacRoman); - atsfont = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault); +#ifdef MAC_OS_X_VERSION_10_5 + font = CTFontCreateWithName(string, size, NULL); +#else + font = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault); +#endif CFRelease(string); } +#ifndef MAC_OS_X_VERSION_10_5 CGContextSelectFont(cr, name, size, kCGEncodingMacRoman); - return atsfont; +#endif + return font; } +#ifdef MAC_OS_X_VERSION_10_5 static PyObject* GraphicsContext_draw_text (GraphicsContext* self, PyObject* args) { @@ -2104,6 +2135,174 @@ const char* weight; const char* italic; float angle; + CTFontRef font; + CGColorRef color; + CGFloat descent; + + CFStringRef keys[2]; + CFTypeRef values[2]; + + CGContextRef cr = self->cr; + if (!cr) + { + PyErr_SetString(PyExc_RuntimeError, "CGContextRef is NULL"); + return NULL; + } + + if(!PyArg_ParseTuple(args, "ffu#Ofssf", + &x, + &y, + &text, + &n, + &family, + &size, + &weight, + &italic, + &angle)) return NULL; + + font = setfont(cr, family, size, weight, italic); + + color = CGColorCreateGenericRGB(self->color[0], + self->color[1], + self->color[2], + self->color[3]); + + keys[0] = kCTFontAttributeName; + keys[1] = kCTForegroundColorAttributeName; + values[0] = font; + values[1] = color; + CFDictionaryRef attributes = CFDictionaryCreate(kCFAllocatorDefault, + (const void**)&keys, + (const void**)&values, + 2, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CGColorRelease(color); + CFRelease(font); + + CFStringRef s = CFStringCreateWithCharacters(kCFAllocatorDefault, text, n); + + CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, + s, + attributes); + CFRelease(s); + CFRelease(attributes); + + CTLineRef line = CTLineCreateWithAttributedString(string); + CFRelease(string); + + CTLineGetTypographicBounds(line, NULL, &descent, NULL); + + if (!line) + { + PyErr_SetString(PyExc_RuntimeError, + "CTLineCreateWithAttributedString failed"); + return NULL; + } + + CGContextSetTextMatrix(cr, CGAffineTransformIdentity); + if (angle) + { + CGContextSaveGState(cr); + CGContextTranslateCTM(cr, x, y); + CGContextRotateCTM(cr, angle*M_PI/180); + CTLineDraw(line, cr); + CGContextRestoreGState(cr); + } + else + { + CGContextSetTextPosition(cr, x, y); + CTLineDraw(line, cr); + } + CFRelease(line); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* +GraphicsContext_get_text_width_height_descent(GraphicsContext* self, PyObject* args) +{ + const UniChar* text; + int n; + PyObject* family; + float size; + const char* weight; + const char* italic; + + CGFloat ascent; + CGFloat descent; + double width; + CGRect rect; + + CTFontRef font; + + CGContextRef cr = self->cr; + if (!cr) + { + PyErr_SetString(PyExc_RuntimeError, "CGContextRef is NULL"); + return NULL; + } + + if(!PyArg_ParseTuple(args, "u#Ofss", + &text, &n, &family, &size, &weight, &italic)) + return NULL; + + font = setfont(cr, family, size, weight, italic); + + CFStringRef keys[1]; + CFTypeRef values[1]; + + keys[0] = kCTFontAttributeName; + values[0] = font; + CFDictionaryRef attributes = CFDictionaryCreate(kCFAllocatorDefault, + (const void**)&keys, + (const void**)&values, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFRelease(font); + + CFStringRef s = CFStringCreateWithCharacters(kCFAllocatorDefault, text, n); + + CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, + s, + attributes); + CFRelease(s); + CFRelease(attributes); + + CTLineRef line = CTLineCreateWithAttributedString(string); + CFRelease(string); + + if (!line) + { + PyErr_SetString(PyExc_RuntimeError, + "CTLineCreateWithAttributedString failed"); + return NULL; + } + + width = CTLineGetTypographicBounds(line, &ascent, &descent, NULL); + rect = CTLineGetImageBounds(line, cr); + + CFRelease(line); + + return Py_BuildValue("fff", width, rect.size.height, descent); +} + +#else + +static PyObject* +GraphicsContext_draw_text (GraphicsContext* self, PyObject* args) +{ + float x; + float y; + const UniChar* text; + int n; + PyObject* family; + float size; + const char* weight; + const char* italic; + float angle; ATSFontRef atsfont; CGContextRef cr = self->cr; if (!cr) @@ -2188,6 +2387,102 @@ return Py_None; } +static PyObject* +GraphicsContext_get_text_width_height_descent(GraphicsContext* self, PyObject* args) +{ + const UniChar* text; + int n; + PyObject* family; + float size; + const char* weight; + const char* italic; + + ATSFontRef atsfont; + + CGContextRef cr = self->cr; + if (!cr) + { + PyErr_SetString(PyExc_RuntimeError, "CGContextRef is NULL"); + return NULL; + } + + if(!PyArg_ParseTuple(args, "u#Ofss", &text, &n, &family, &size, &weight, &italic)) return NULL; + + atsfont = setfont(cr, family, size, weight, italic); + + OSStatus status = noErr; + ATSUAttributeTag tags[] = {kATSUFontTag, + kATSUSizeTag, + kATSUQDBoldfaceTag, + kATSUQDItalicTag}; + ByteCount sizes[] = {sizeof(ATSUFontID), + sizeof(Fixed), + sizeof(Boolean), + sizeof(Boolean)}; + Fixed atsuSize = Long2Fix(size); + Boolean isBold = FALSE; /* setfont takes care of this */ + Boolean isItalic = FALSE; /* setfont takes care of this */ + ATSUAttributeValuePtr values[] = {&atsfont, &atsuSize, &isBold, &isItalic}; + + status = ATSUSetAttributes(style, 4, tags, sizes, values); + if (status!=noErr) + { + PyErr_SetString(PyExc_RuntimeError, "ATSUSetAttributes failed"); + return NULL; + } + + status = ATSUSetTextPointerLocation(layout, + text, + kATSUFromTextBeginning, /* offset from beginning */ + kATSUToTextEnd, /* length of text range */ + n); /* length of text buffer */ + if (status!=noErr) + { + PyErr_SetString(PyExc_RuntimeError, + "ATSUCreateTextLayoutWithTextPtr failed"); + return NULL; + } + + status = ATSUSetRunStyle(layout, + style, + kATSUFromTextBeginning, + kATSUToTextEnd); + if (status!=noErr) + { + PyErr_SetString(PyExc_RuntimeError, "ATSUSetRunStyle failed"); + return NULL; + } + + ATSUAttributeTag tag = kATSUCGContextTag; + ByteCount bc = sizeof (CGContextRef); + ATSUAttributeValuePtr value = &cr; + status = ATSUSetLayoutControls(layout, 1, &tag, &bc, &value); + if (status!=noErr) + { + PyErr_SetString(PyExc_RuntimeError, "ATSUSetLayoutControls failed"); + return NULL; + } + + ATSUTextMeasurement before; + ATSUTextMeasurement after; + ATSUTextMeasurement ascent; + ATSUTextMeasurement descent; + status = ATSUGetUnjustifiedBounds(layout, + kATSUFromTextBeginning, kATSUToTextEnd, + &before, &after, &ascent, &descent); + if (status!=noErr) + { + PyErr_SetString(PyExc_RuntimeError, "ATSUGetUnjustifiedBounds failed"); + return NULL; + } + + const float width = FixedToFloat(after-before); + const float height = FixedToFloat(ascent-descent); + + return Py_BuildValue("fff", width, height, FixedToFloat(descent)); +} +#endif + static void _data_provider_release(void* info, const void* data, size_t size) { PyObject* image = (PyObject*)info; @@ -2293,101 +2588,6 @@ } static PyObject* -GraphicsContext_get_text_width_height_descent(GraphicsContext* self, PyObject* args) -{ - const UniChar* text; - int n; - PyObject* family; - float size; - const char* weight; - const char* italic; - - ATSFontRef atsfont; - - CGContextRef cr = self->cr; - if (!cr) - { - PyErr_SetString(PyExc_RuntimeError, "CGContextRef is NULL"); - return NULL; - } - - if(!PyArg_ParseTuple(args, "u#Ofss", &text, &n, &family, &size, &weight, &italic)) return NULL; - - atsfont = setfont(cr, family, size, weight, italic); - - OSStatus status = noErr; - ATSUAttributeTag tags[] = {kATSUFontTag, - kATSUSizeTag, - kATSUQDBoldfaceTag, - kATSUQDItalicTag}; - ByteCount sizes[] = {sizeof(ATSUFontID), - sizeof(Fixed), - sizeof(Boolean), - sizeof(Boolean)}; - Fixed atsuSize = Long2Fix(size); - Boolean isBold = FALSE; /* setfont takes care of this */ - Boolean isItalic = FALSE; /* setfont takes care of this */ - ATSUAttributeValuePtr values[] = {&atsfont, &atsuSize, &isBold, &isItalic}; - - status = ATSUSetAttributes(style, 4, tags, sizes, values); - if (status!=noErr) - { - PyErr_SetString(PyExc_RuntimeError, "ATSUSetAttributes failed"); - return NULL; - } - - status = ATSUSetTextPointerLocation(layout, - text, - kATSUFromTextBeginning, /* offset from beginning */ - kATSUToTextEnd, /* length of text range */ - n); /* length of text buffer */ - if (status!=noErr) - { - PyErr_SetString(PyExc_RuntimeError, - "ATSUCreateTextLayoutWithTextPtr failed"); - return NULL; - } - - status = ATSUSetRunStyle(layout, - style, - kATSUFromTextBeginning, - kATSUToTextEnd); - if (status!=noErr) - { - PyErr_SetString(PyExc_RuntimeError, "ATSUSetRunStyle failed"); - return NULL; - } - - ATSUAttributeTag tag = kATSUCGContextTag; - ByteCount bc = sizeof (CGContextRef); - ATSUAttributeValuePtr value = &cr; - status = ATSUSetLayoutControls(layout, 1, &tag, &bc, &value); - if (status!=noErr) - { - PyErr_SetString(PyExc_RuntimeError, "ATSUSetLayoutControls failed"); - return NULL; - } - - ATSUTextMeasurement before; - ATSUTextMeasurement after; - ATSUTextMeasurement ascent; - ATSUTextMeasurement descent; - status = ATSUGetUnjustifiedBounds(layout, - kATSUFromTextBeginning, kATSUToTextEnd, - &before, &after, &ascent, &descent); - if (status!=noErr) - { - PyErr_SetString(PyExc_RuntimeError, "ATSUGetUnjustifiedBounds failed"); - return NULL; - } - - const float width = FixedToFloat(after-before); - const float height = FixedToFloat(ascent-descent); - - return Py_BuildValue("fff", width, height, FixedToFloat(descent)); -} - -static PyObject* GraphicsContext_draw_image(GraphicsContext* self, PyObject* args) { float x, y; @@ -2621,7 +2821,11 @@ "_macosx.GraphicsContext", /*tp_name*/ sizeof(GraphicsContext), /*tp_basicsize*/ 0, /*tp_itemsize*/ +#ifdef MAC_OS_X_VERSION_10_5 + 0, /*tp_dealloc*/ +#else (destructor)GraphicsContext_dealloc, /*tp_dealloc*/ +#endif 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -2826,15 +3030,18 @@ int n; const unichar* characters; NSSize size; + double width, height; if(!view) { PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } - if(!PyArg_ParseTuple(args, "u#ff", - &characters, &n, - &size.width, &size.height)) return NULL; + /* NSSize contains CGFloat; cannot use size directly */ + if(!PyArg_ParseTuple(args, "u#dd", + &characters, &n, &width, &height)) return NULL; + size.width = width; + size.height = height; /* This function may be called from inside the event loop, when an * autorelease pool is available, or from Python, when no autorelease @@ -4492,6 +4699,86 @@ PyGILState_Release(gstate); } +- (void)rightMouseDown:(NSEvent *)event +{ + int x, y; + int num = 3; + PyObject* result; + PyGILState_STATE gstate; + NSPoint location = [event locationInWindow]; + location = [self convertPoint: location fromView: nil]; + x = location.x; + y = location.y; + gstate = PyGILState_Ensure(); + result = PyObject_CallMethod(canvas, "button_press_event", "iii", x, y, num); + if(result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); +} + +- (void)rightMouseUp:(NSEvent *)event +{ + int x, y; + int num = 3; + PyObject* result; + PyGILState_STATE gstate; + NSPoint location = [event locationInWindow]; + location = [self convertPoint: location fromView: nil]; + x = location.x; + y = location.y; + gstate = PyGILState_Ensure(); + result = PyObject_CallMethod(canvas, "button_release_event", "iii", x, y, num); + if(result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); +} + +- (void)otherMouseDown:(NSEvent *)event +{ + int x, y; + int num = 2; + PyObject* result; + PyGILState_STATE gstate; + NSPoint location = [event locationInWindow]; + location = [self convertPoint: location fromView: nil]; + x = location.x; + y = location.y; + gstate = PyGILState_Ensure(); + result = PyObject_CallMethod(canvas, "button_press_event", "iii", x, y, num); + if(result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); +} + +- (void)otherMouseUp:(NSEvent *)event +{ + int x, y; + int num = 2; + PyObject* result; + PyGILState_STATE gstate; + NSPoint location = [event locationInWindow]; + location = [self convertPoint: location fromView: nil]; + x = location.x; + y = location.y; + gstate = PyGILState_Ensure(); + result = PyObject_CallMethod(canvas, "button_release_event", "iii", x, y, num); + if(result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); +} + - (void)setRubberband:(NSRect)rect { if (!NSIsEmptyRect(rubberband)) [self setNeedsDisplayInRect: rubberband]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7322 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7322&view=rev Author: mdboom Date: 2009年07月31日 13:49:33 +0000 (2009年7月31日) Log Message: ----------- Removed merge tracking for "svnmerge" for https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7318 + /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7318 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7320 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7320&view=rev Author: mdboom Date: 2009年07月31日 13:46:28 +0000 (2009年7月31日) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-7315" from https://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib Property Changed: ---------------- branches/v0_99_maint/ Property changes on: branches/v0_99_maint ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 + /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /trunk/matplotlib:1-7315 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7321 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7321&view=rev Author: mdboom Date: 2009年07月31日 13:46:28 +0000 (2009年7月31日) Log Message: ----------- Update coding guide for 0.99 version Modified Paths: -------------- trunk/matplotlib/doc/devel/coding_guide.rst Modified: trunk/matplotlib/doc/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/doc/devel/coding_guide.rst 2009年07月31日 13:46:28 UTC (rev 7320) +++ trunk/matplotlib/doc/devel/coding_guide.rst 2009年07月31日 13:46:28 UTC (rev 7321) @@ -27,12 +27,12 @@ Branch checkouts, eg the maintenance branch:: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\ - v0_91_maint mpl91 --username=youruser --password=yourpass + v0_99_maint mpl99 --username=youruser --password=yourpass -The current release of the trunk is in the 0.98.5 maintenance branch:: +The current release of the trunk is in the 0.99.x maintenance branch:: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/\ - v0_98_5_maint mpl98.5 --username=youruser --password=yourpass + v0_99_maint mpl99 --username=youruser --password=yourpass Committing changes @@ -96,7 +96,7 @@ svnmerge.py merge -S BRANCHNAME Where BRANCHNAME is the name of the branch to merge *from*, - e.g. v0_98_5_maint. + e.g. v0_99_maint. If you wish to merge only specific revisions (in an unusual situation), do:: @@ -130,17 +130,17 @@ with this. * Creating a new branch from the trunk (if the release version is - 0.98.5 at revision 6573):: + 0.99 at revision 6573):: > svn copy \ - https://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib@6573 \ - https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint \ - -m "Creating maintenance branch for 0.98.5" + https://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib@7315 \ + https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint \ + -m "Creating maintenance branch for 0.99" * You can add a new branch for the trunk to "track" using "svnmerge.py init", e.g., from a working copy of the trunk:: - > svnmerge.py init https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint + > svnmerge.py init https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint property 'svnmerge-integrated' set on '.' After doing a "svn commit" on this, this merge tracking is available @@ -150,7 +150,7 @@ * Tracking can later be removed with the "svnmerge.py uninit" command, e.g.:: - > svnmerge.py -S v0_9_5_maint uninit + > svnmerge.py -S v0_99_maint uninit .. _using-git: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7314 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7314&view=rev Author: jdh2358 Date: 2009年07月31日 13:28:27 +0000 (2009年7月31日) Log Message: ----------- fixed pyplot typo in gridlines Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2009年07月31日 13:15:16 UTC (rev 7313) +++ trunk/matplotlib/examples/tests/backend_driver.py 2009年07月31日 13:28:27 UTC (rev 7314) @@ -392,7 +392,8 @@ doc = __doc__.split('\n\n') op = OptionParser(description=doc[0].strip(), usage='%prog [options] [--] [backends and switches]', - epilog='\n'.join(doc[1:])) + #epilog='\n'.join(doc[1:]) # epilog not supported on my python2.4 machine: JDH + ) op.disable_interspersed_args() op.set_defaults(dirs='pylab,api,units,mplot3d', clean=False, coverage=False, valgrind=False) Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2009年07月31日 13:15:16 UTC (rev 7313) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009年07月31日 13:28:27 UTC (rev 7314) @@ -1102,7 +1102,7 @@ if not isinstance(ax, PolarAxes): raise RuntimeError('rgrids only defined for polar axes') if len(args)==0: - lines = ax.yaxis.gridlines() + lines = ax.yaxis.get_gridlines() labels = ax.yaxis.get_ticklabels() else: lines, labels = ax.set_rgrids(*args, **kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7319 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7319&view=rev Author: mdboom Date: 2009年07月31日 13:41:58 +0000 (2009年7月31日) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-7318" from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 + /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7318 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7318 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7318&view=rev Author: mdboom Date: 2009年07月31日 13:39:49 +0000 (2009年7月31日) Log Message: ----------- Creating 0.99.x maintenance branch Added Paths: ----------- branches/v0_99_maint/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7317 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7317&view=rev Author: jdh2358 Date: 2009年07月31日 13:38:56 +0000 (2009年7月31日) Log Message: ----------- remove community choice vote from website Modified Paths: -------------- trunk/matplotlib/doc/_templates/indexsidebar.html trunk/matplotlib/doc/mpl_toolkits/mplot3d/api.rst trunk/matplotlib/doc/users/toolkits.rst trunk/matplotlib/examples/tests/backend_driver.py Modified: trunk/matplotlib/doc/_templates/indexsidebar.html =================================================================== --- trunk/matplotlib/doc/_templates/indexsidebar.html 2009年07月31日 13:36:38 UTC (rev 7316) +++ trunk/matplotlib/doc/_templates/indexsidebar.html 2009年07月31日 13:38:56 UTC (rev 7317) @@ -1,19 +1,13 @@ <h3>News</h3> + <p>Please <a href="http://sourceforge.net/project/project_donations.php?group_id=80706">donate</a> to support matplotlib development.</p> + <p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">video lecture</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>Machine Learning Open Source Software</i></a>. </p> -<p>Nominate matplotlib for a community choice award by clicking the -image below -- suggested category "Best Project for Academia" for -software which "helps you hit the books, analyze global trends, or -just understand the world a little bit better than you did before": -<a href="http://sourceforge.net/images/cca/cca_nominate.png" border="0"/></a> -</p> - - <h3>Download</h3> <p>Current version: <b>{{ version }}</b></p> Modified: trunk/matplotlib/doc/mpl_toolkits/mplot3d/api.rst =================================================================== --- trunk/matplotlib/doc/mpl_toolkits/mplot3d/api.rst 2009年07月31日 13:36:38 UTC (rev 7316) +++ trunk/matplotlib/doc/mpl_toolkits/mplot3d/api.rst 2009年07月31日 13:38:56 UTC (rev 7317) @@ -7,7 +7,6 @@ .. automodule:: mpl_toolkits.mplot3d.axes3d :members: - :exclude-members: contour3D, contourf3D, plot3D, scatter3D :show-inheritance: :mod:`mpl_toolkits.mplot3d.art3d` Modified: trunk/matplotlib/doc/users/toolkits.rst =================================================================== --- trunk/matplotlib/doc/users/toolkits.rst 2009年07月31日 13:36:38 UTC (rev 7316) +++ trunk/matplotlib/doc/users/toolkits.rst 2009年07月31日 13:38:56 UTC (rev 7317) @@ -66,5 +66,5 @@ distributed with matplotlib source. .. image:: ../_static/demo_axes_grid.png - + See :ref:`toolkit_axesgrid-index` for documentations. Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2009年07月31日 13:36:38 UTC (rev 7316) +++ trunk/matplotlib/examples/tests/backend_driver.py 2009年07月31日 13:38:56 UTC (rev 7317) @@ -336,7 +336,6 @@ for fullpath in testcases: print ('\tdriving %-40s' % (fullpath)), sys.stdout.flush() - fpath, fname = os.path.split(fullpath) if fname in exclude: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7316 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7316&view=rev Author: mdboom Date: 2009年07月31日 13:36:38 +0000 (2009年7月31日) Log Message: ----------- Tagging 0.99.0.rc1 Added Paths: ----------- tags/v0_99_0_rc1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7315 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7315&view=rev Author: mdboom Date: 2009年07月31日 13:33:06 +0000 (2009年7月31日) Log Message: ----------- Tagging 0.99.0.rc1 release Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/log_demo.py trunk/matplotlib/lib/matplotlib/__init__.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009年07月31日 13:28:27 UTC (rev 7314) +++ trunk/matplotlib/CHANGELOG 2009年07月31日 13:33:06 UTC (rev 7315) @@ -1,3 +1,7 @@ +====================================================================== + +2009年07月31日 Tagging 0.99.0.rc1 at 7314 - MGD + 2009年07月30日 Add set_cmap and register_cmap, and improve get_cmap, to provide convenient handling of user-generated colormaps. Reorganized _cm and cm modules. - EF Modified: trunk/matplotlib/examples/pylab_examples/log_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/log_demo.py 2009年07月31日 13:28:27 UTC (rev 7314) +++ trunk/matplotlib/examples/pylab_examples/log_demo.py 2009年07月31日 13:33:06 UTC (rev 7315) @@ -19,7 +19,7 @@ # log x and y axis plt.subplot(223) -plt.loglog(t, 20*np.exp(-t/10.0), basex=4) +plt.loglog(t, 20*np.exp(-t/10.0), basex=2) plt.grid(True) plt.title('loglog base 4 on x') Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2009年07月31日 13:28:27 UTC (rev 7314) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2009年07月31日 13:33:06 UTC (rev 7315) @@ -89,7 +89,7 @@ """ from __future__ import generators -__version__ = '0.98.6svn' +__version__ = '0.99.0.rc1' __revision__ = '$Revision$' __date__ = '$Date$' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7313 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7313&view=rev Author: jdh2358 Date: 2009年07月31日 13:15:16 +0000 (2009年7月31日) Log Message: ----------- make rgrids return grid, not tick, lines Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/projections/polar.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009年07月31日 05:22:37 UTC (rev 7312) +++ trunk/matplotlib/CHANGELOG 2009年07月31日 13:15:16 UTC (rev 7313) @@ -4421,4 +4421,3 @@ 2003年11月21日 - make a dash-dot dict for the GC 2003年12月15日 - fix install path bug -t Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/polar.py 2009年07月31日 05:22:37 UTC (rev 7312) +++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2009年07月31日 13:15:16 UTC (rev 7313) @@ -397,7 +397,7 @@ self._r_label2_position.clear().translate(angle, -self._rpad * rmax) for t in self.yaxis.get_ticklabels(): t.update(kwargs) - return self.yaxis.get_ticklines(), self.yaxis.get_ticklabels() + return self.yaxis.get_gridlines(), self.yaxis.get_ticklabels() set_rgrids.__doc__ = cbook.dedent(set_rgrids.__doc__) % kwdocd Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2009年07月31日 05:22:37 UTC (rev 7312) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009年07月31日 13:15:16 UTC (rev 7313) @@ -1102,7 +1102,7 @@ if not isinstance(ax, PolarAxes): raise RuntimeError('rgrids only defined for polar axes') if len(args)==0: - lines = ax.yaxis.get_ticklines() + lines = ax.yaxis.gridlines() labels = ax.yaxis.get_ticklabels() else: lines, labels = ax.set_rgrids(*args, **kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7312 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7312&view=rev Author: efiring Date: 2009年07月31日 05:22:37 +0000 (2009年7月31日) Log Message: ----------- Removed the colormap data caching--it was trying to solve a non-problem. Upon installation, the colormap data in _cm.py is compiled into _cm.pyc, and importing that takes negligible time. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/cm.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009年07月31日 02:48:18 UTC (rev 7311) +++ trunk/matplotlib/CHANGELOG 2009年07月31日 05:22:37 UTC (rev 7312) @@ -1,7 +1,6 @@ 2009年07月30日 Add set_cmap and register_cmap, and improve get_cmap, to provide convenient handling of user-generated - colormaps. Reorganized _cm and cm modules, and added - caching of the color data to reduce startup time. - EF + colormaps. Reorganized _cm and cm modules. - EF 2009年07月28日 Quiver speed improved, thanks to tip by Ray Speth. -EF Modified: trunk/matplotlib/lib/matplotlib/cm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cm.py 2009年07月31日 02:48:18 UTC (rev 7311) +++ trunk/matplotlib/lib/matplotlib/cm.py 2009年07月31日 05:22:37 UTC (rev 7312) @@ -1,44 +1,20 @@ """ -This module contains the instantiations of color mapping classes +This module provides a large set of colormaps, functions for +registering new colormaps and for getting a colormap by name, +and a mixin class for adding color mapping functionality. + """ + import os -try: - import cPickle as pickle -except ImportError: - import pickle - import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cbook as cbook +from matplotlib._cm import datad -LUTSIZE = mpl.rcParams['image.lut'] -_cmcache = os.path.join(mpl.get_configdir(), 'colormaps.cache') - -loaded = False -try: - c = open(_cmcache) - datad = pickle.load(c) - c.close() - mpl.verbose.report("Using colormaps from %s" % _cmcache) - loaded = True -except: - mpl.verbose.report("Could not load colormaps from %s" % _cmcache) - -if not loaded: - from matplotlib._cm import datad - - try: - c = open(_cmcache, 'w') - pickle.dump(datad, c, 2) - c.close() - mpl.verbose.report("New colormap cache in %s" % _cmcache) - except: - mpl.verbose.report("Failed to generate colormap cache") - cmap_d = dict() # reverse all the colormaps. @@ -51,7 +27,10 @@ data_r[key] = valnew return data_r +LUTSIZE = mpl.rcParams['image.lut'] + _cmapnames = datad.keys() # need this list because datad is changed in loop + for cmapname in _cmapnames: cmapname_r = cmapname+'_r' cmapdat_r = revcmap(datad[cmapname]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7311 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7311&view=rev Author: efiring Date: 2009年07月31日 02:48:18 +0000 (2009年7月31日) Log Message: ----------- Cache the color data to reduce startup time. Also, cmap kwargs now accept colormap names as strings. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/_cm.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/cm.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009年07月30日 21:50:10 UTC (rev 7310) +++ trunk/matplotlib/CHANGELOG 2009年07月31日 02:48:18 UTC (rev 7311) @@ -1,6 +1,7 @@ 2009年07月30日 Add set_cmap and register_cmap, and improve get_cmap, to provide convenient handling of user-generated - colormaps. - EF + colormaps. Reorganized _cm and cm modules, and added + caching of the color data to reduce startup time. - EF 2009年07月28日 Quiver speed improved, thanks to tip by Ray Speth. -EF Modified: trunk/matplotlib/lib/matplotlib/_cm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_cm.py 2009年07月30日 21:50:10 UTC (rev 7310) +++ trunk/matplotlib/lib/matplotlib/_cm.py 2009年07月31日 02:48:18 UTC (rev 7311) @@ -1,25 +1,15 @@ """ -Color data and pre-defined cmap objects. +Nothing here but dictionaries for generating LinearSegmentedColormaps, +and a dictionary of these dictionaries. -This is a helper for cm.py, originally part of that file. -Separating the data (this file) from cm.py makes both easier -to deal with. - -Objects visible in cm.py are the individual cmap objects ('autumn', -etc.) and a dictionary, 'datad', including all of these objects. """ -import matplotlib as mpl -import matplotlib.colors as colors -LUTSIZE = mpl.rcParams['image.lut'] - _binary_data = { 'red' : ((0., 1., 1.), (1., 0., 0.)), 'green': ((0., 1., 1.), (1., 0., 0.)), 'blue' : ((0., 1., 1.), (1., 0., 0.)) } - _bone_data = {'red': ((0., 0., 0.),(1.0, 1.0, 1.0)), 'green': ((0., 0., 0.),(1.0, 1.0, 1.0)), 'blue': ((0., 0., 0.),(1.0, 1.0, 1.0))} @@ -379,44 +369,6 @@ (1.0, 0.80, 0.80)]} -autumn = colors.LinearSegmentedColormap('autumn', _autumn_data, LUTSIZE) -bone = colors.LinearSegmentedColormap('bone ', _bone_data, LUTSIZE) -binary = colors.LinearSegmentedColormap('binary ', _binary_data, LUTSIZE) -cool = colors.LinearSegmentedColormap('cool', _cool_data, LUTSIZE) -copper = colors.LinearSegmentedColormap('copper', _copper_data, LUTSIZE) -flag = colors.LinearSegmentedColormap('flag', _flag_data, LUTSIZE) -gray = colors.LinearSegmentedColormap('gray', _gray_data, LUTSIZE) -hot = colors.LinearSegmentedColormap('hot', _hot_data, LUTSIZE) -hsv = colors.LinearSegmentedColormap('hsv', _hsv_data, LUTSIZE) -jet = colors.LinearSegmentedColormap('jet', _jet_data, LUTSIZE) -pink = colors.LinearSegmentedColormap('pink', _pink_data, LUTSIZE) -prism = colors.LinearSegmentedColormap('prism', _prism_data, LUTSIZE) -spring = colors.LinearSegmentedColormap('spring', _spring_data, LUTSIZE) -summer = colors.LinearSegmentedColormap('summer', _summer_data, LUTSIZE) -winter = colors.LinearSegmentedColormap('winter', _winter_data, LUTSIZE) -spectral = colors.LinearSegmentedColormap('spectral', _spectral_data, LUTSIZE) - - - -datad = { - 'autumn': _autumn_data, - 'bone': _bone_data, - 'binary': _binary_data, - 'cool': _cool_data, - 'copper': _copper_data, - 'flag': _flag_data, - 'gray' : _gray_data, - 'hot': _hot_data, - 'hsv': _hsv_data, - 'jet' : _jet_data, - 'pink': _pink_data, - 'prism': _prism_data, - 'spring': _spring_data, - 'summer': _summer_data, - 'winter': _winter_data, - 'spectral': _spectral_data - } - # 34 colormaps based on color specifications and designs # developed by Cynthia Brewer (http://colorbrewer.org). # The ColorBrewer palettes have been included under the terms @@ -5859,48 +5811,26 @@ 0.0078431377187371254, 0.0078431377187371254), (1.0, 0.0039215688593685627, 0.0039215688593685627)]} -Accent = colors.LinearSegmentedColormap('Accent', _Accent_data, LUTSIZE) -Blues = colors.LinearSegmentedColormap('Blues', _Blues_data, LUTSIZE) -BrBG = colors.LinearSegmentedColormap('BrBG', _BrBG_data, LUTSIZE) -BuGn = colors.LinearSegmentedColormap('BuGn', _BuGn_data, LUTSIZE) -BuPu = colors.LinearSegmentedColormap('BuPu', _BuPu_data, LUTSIZE) -Dark2 = colors.LinearSegmentedColormap('Dark2', _Dark2_data, LUTSIZE) -GnBu = colors.LinearSegmentedColormap('GnBu', _GnBu_data, LUTSIZE) -Greens = colors.LinearSegmentedColormap('Greens', _Greens_data, LUTSIZE) -Greys = colors.LinearSegmentedColormap('Greys', _Greys_data, LUTSIZE) -Oranges = colors.LinearSegmentedColormap('Oranges', _Oranges_data, LUTSIZE) -OrRd = colors.LinearSegmentedColormap('OrRd', _OrRd_data, LUTSIZE) -Paired = colors.LinearSegmentedColormap('Paired', _Paired_data, LUTSIZE) -Pastel1 = colors.LinearSegmentedColormap('Pastel1', _Pastel1_data, LUTSIZE) -Pastel2 = colors.LinearSegmentedColormap('Pastel2', _Pastel2_data, LUTSIZE) -PiYG = colors.LinearSegmentedColormap('PiYG', _PiYG_data, LUTSIZE) -PRGn = colors.LinearSegmentedColormap('PRGn', _PRGn_data, LUTSIZE) -PuBu = colors.LinearSegmentedColormap('PuBu', _PuBu_data, LUTSIZE) -PuBuGn = colors.LinearSegmentedColormap('PuBuGn', _PuBuGn_data, LUTSIZE) -PuOr = colors.LinearSegmentedColormap('PuOr', _PuOr_data, LUTSIZE) -PuRd = colors.LinearSegmentedColormap('PuRd', _PuRd_data, LUTSIZE) -Purples = colors.LinearSegmentedColormap('Purples', _Purples_data, LUTSIZE) -RdBu = colors.LinearSegmentedColormap('RdBu', _RdBu_data, LUTSIZE) -RdGy = colors.LinearSegmentedColormap('RdGy', _RdGy_data, LUTSIZE) -RdPu = colors.LinearSegmentedColormap('RdPu', _RdPu_data, LUTSIZE) -RdYlBu = colors.LinearSegmentedColormap('RdYlBu', _RdYlBu_data, LUTSIZE) -RdYlGn = colors.LinearSegmentedColormap('RdYlGn', _RdYlGn_data, LUTSIZE) -Reds = colors.LinearSegmentedColormap('Reds', _Reds_data, LUTSIZE) -Set1 = colors.LinearSegmentedColormap('Set1', _Set1_data, LUTSIZE) -Set2 = colors.LinearSegmentedColormap('Set2', _Set2_data, LUTSIZE) -Set3 = colors.LinearSegmentedColormap('Set3', _Set3_data, LUTSIZE) -Spectral = colors.LinearSegmentedColormap('Spectral', _Spectral_data, LUTSIZE) -YlGn = colors.LinearSegmentedColormap('YlGn', _YlGn_data, LUTSIZE) -YlGnBu = colors.LinearSegmentedColormap('YlGnBu', _YlGnBu_data, LUTSIZE) -YlOrBr = colors.LinearSegmentedColormap('YlOrBr', _YlOrBr_data, LUTSIZE) -YlOrRd = colors.LinearSegmentedColormap('YlOrRd', _YlOrRd_data, LUTSIZE) -gist_earth = colors.LinearSegmentedColormap('gist_earth', _gist_earth_data, LUTSIZE) -gist_gray = colors.LinearSegmentedColormap('gist_gray', _gist_gray_data, LUTSIZE) -gist_heat = colors.LinearSegmentedColormap('gist_heat', _gist_heat_data, LUTSIZE) -gist_ncar = colors.LinearSegmentedColormap('gist_ncar', _gist_ncar_data, LUTSIZE) -gist_rainbow = colors.LinearSegmentedColormap('gist_rainbow', _gist_rainbow_data, LUTSIZE) -gist_stern = colors.LinearSegmentedColormap('gist_stern', _gist_stern_data, LUTSIZE) -gist_yarg = colors.LinearSegmentedColormap('gist_yarg', _gist_yarg_data, LUTSIZE) +datad = { + 'autumn': _autumn_data, + 'bone': _bone_data, + 'binary': _binary_data, + 'cool': _cool_data, + 'copper': _copper_data, + 'flag': _flag_data, + 'gray' : _gray_data, + 'hot': _hot_data, + 'hsv': _hsv_data, + 'jet' : _jet_data, + 'pink': _pink_data, + 'prism': _prism_data, + 'spring': _spring_data, + 'summer': _summer_data, + 'winter': _winter_data, + 'spectral': _spectral_data + } + + datad['Accent']=_Accent_data datad['Blues']=_Blues_data datad['BrBG']=_BrBG_data @@ -5944,19 +5874,7 @@ datad['gist_stern']=_gist_stern_data datad['gist_yarg']=_gist_yarg_data -# reverse all the colormaps. -# reversed colormaps have '_r' appended to the name. -def revcmap(data): - data_r = {} - for key, val in data.iteritems(): - valnew = [(1.-a, b, c) for a, b, c in reversed(val)] - data_r[key] = valnew - return data_r -cmapnames = datad.keys() -for cmapname in cmapnames: - cmapname_r = cmapname+'_r' - cmapdat_r = revcmap(datad[cmapname]) - datad[cmapname_r] = cmapdat_r - locals()[cmapname_r] = colors.LinearSegmentedColormap(cmapname_r, cmapdat_r, LUTSIZE) + + Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2009年07月30日 21:50:10 UTC (rev 7310) +++ trunk/matplotlib/lib/matplotlib/axes.py 2009年07月31日 02:48:18 UTC (rev 7311) @@ -3911,12 +3911,12 @@ *bbox_to_anchor* keyword argument. bbox_to_anchor can be an instance of BboxBase(or its derivatives) or a tuple of 2 or 4 floats. For example, - + loc = 'upper right', bbox_to_anchor = (0.5, 0.5) will place the legend so that the upper right corner of the legend at the center of the axes. - + The legend location can be specified in other coordinate, by using the *bbox_transform* keyword. @@ -3946,7 +3946,7 @@ *fancybox*: [ None | False | True ] if True, draw a frame with a round fancybox. If None, use rc - + *shadow*: [ None | False | True ] If *True*, draw a shadow behind legend. If *None*, use rc settings. @@ -5172,9 +5172,9 @@ arguments will be used only if *c* is an array of floats. *cmap*: [ None | Colormap ] - A :class:`matplotlib.colors.Colormap` instance. If *None*, - defaults to rc ``image.cmap``. *cmap* is only used if *c* - is an array of floats. + A :class:`matplotlib.colors.Colormap` instance or registered + name. If *None*, defaults to rc ``image.cmap``. *cmap* is + only used if *c* is an array of floats. *norm*: [ None | Normalize ] A :class:`matplotlib.colors.Normalize` instance is used to @@ -5370,7 +5370,6 @@ if colors is None: if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) collection.set_array(np.asarray(c)) collection.set_cmap(cmap) collection.set_norm(norm) @@ -5712,7 +5711,6 @@ accum = bins.searchsorted(accum) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) collection.set_array(accum) collection.set_cmap(cmap) collection.set_norm(norm) @@ -6245,7 +6243,6 @@ if not self._hold: self.cla() if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) if aspect is None: aspect = rcParams['image.aspect'] self.set_aspect(aspect) im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent, @@ -6490,7 +6487,6 @@ collection.set_alpha(alpha) collection.set_array(C) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) collection.set_cmap(cmap) collection.set_norm(norm) if vmin is not None or vmax is not None: @@ -6612,7 +6608,6 @@ collection.set_alpha(alpha) collection.set_array(C) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) collection.set_cmap(cmap) collection.set_norm(norm) if vmin is not None or vmax is not None: @@ -6719,7 +6714,6 @@ vmin = kwargs.pop('vmin', None) vmax = kwargs.pop('vmax', None) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) - if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) C = args[-1] nr, nc = C.shape Modified: trunk/matplotlib/lib/matplotlib/cm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cm.py 2009年07月30日 21:50:10 UTC (rev 7310) +++ trunk/matplotlib/lib/matplotlib/cm.py 2009年07月31日 02:48:18 UTC (rev 7311) @@ -1,25 +1,68 @@ """ This module contains the instantiations of color mapping classes """ +import os +try: + import cPickle as pickle +except ImportError: + import pickle + import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cbook as cbook -from matplotlib._cm import * -# Dictionary for user-registered colormaps: +LUTSIZE = mpl.rcParams['image.lut'] + +_cmcache = os.path.join(mpl.get_configdir(), 'colormaps.cache') + +loaded = False +try: + c = open(_cmcache) + datad = pickle.load(c) + c.close() + mpl.verbose.report("Using colormaps from %s" % _cmcache) + loaded = True +except: + mpl.verbose.report("Could not load colormaps from %s" % _cmcache) + +if not loaded: + from matplotlib._cm import datad + + try: + c = open(_cmcache, 'w') + pickle.dump(datad, c, 2) + c.close() + mpl.verbose.report("New colormap cache in %s" % _cmcache) + except: + mpl.verbose.report("Failed to generate colormap cache") + cmap_d = dict() -# Using this second dictionary allows us to handle any -# Colormap instance; the built-in datad is only for -# LinearSegmentedColormaps. The advantage of keeping -# datad is that it delays the generation of the Colormap -# instance until it is actually needed. Generating the -# instance is fast enough, and typically done few enough -# times, that there is no need to cache the result. +# reverse all the colormaps. +# reversed colormaps have '_r' appended to the name. +def revcmap(data): + data_r = {} + for key, val in data.iteritems(): + valnew = [(1.0-a, b, c) for a, b, c in reversed(val)] + data_r[key] = valnew + return data_r + +_cmapnames = datad.keys() # need this list because datad is changed in loop +for cmapname in _cmapnames: + cmapname_r = cmapname+'_r' + cmapdat_r = revcmap(datad[cmapname]) + datad[cmapname_r] = cmapdat_r + cmap_d[cmapname] = colors.LinearSegmentedColormap( + cmapname, datad[cmapname], LUTSIZE) + cmap_d[cmapname_r] = colors.LinearSegmentedColormap( + cmapname_r, cmapdat_r, LUTSIZE) + +locals().update(cmap_d) + def register_cmap(name=None, cmap=None, data=None, lut=None): """ Add a colormap to the set recognized by :func:`get_cmap`. @@ -67,6 +110,11 @@ If *name* is a :class:`colors.Colormap` instance, it will be returned. + + If *lut* is not None it must be an integer giving the number of + entries desired in the lookup table, and *name* must be a + standard mpl colormap name with a corresponding data dictionary + in *datad*. """ if name is None: name = mpl.rcParams['image.cmap'] @@ -75,15 +123,13 @@ return name if name in cmap_d: - return cmap_d[name] + if lut is None: + return cmap_d[name] + elif name in datad: + return colors.LinearSegmentedColormap(name, datad[name], lut) + else: + raise ValueError("Colormap %s is not recognized" % name) - if name not in datad: - raise ValueError("%s is not a known colormap name" % name) - - if lut is None: - lut = mpl.rcParams['image.lut'] - return colors.LinearSegmentedColormap(name, datad[name], lut) - class ScalarMappable: """ This is a mixin class to support scalar -> RGBA mapping. Handles @@ -105,7 +151,7 @@ self._A = None self.norm = norm - self.cmap = cmap + self.cmap = get_cmap(cmap) self.colorbar = None self.update_dict = {'array':False} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.