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
|
|
From: <js...@us...> - 2009-07-23 12:10:28
|
Revision: 7287
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7287&view=rev
Author: jswhit
Date: 2009-07-23 12:10:18 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
add 'interp' keyword to griddata. Can be set to 'linear' to get faster
linear interpolation using Delaunay package. Default is 'nn' (natural
neighbor).
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-22 13:58:18 UTC (rev 7286)
+++ trunk/matplotlib/CHANGELOG 2009-07-23 12:10:18 UTC (rev 7287)
@@ -1,3 +1,7 @@
+2009-07-22 Added an 'interp' keyword to griddata so the faster linear
+ interpolation method can be chosen. Default is 'nn', so
+ default behavior (using natural neighbor method) is unchanged (JSW)
+
2009-07-22 Improved boilerplate.py so that it generates the correct
signatures for pyplot functions. - JKS
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2009-07-22 13:58:18 UTC (rev 7286)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-07-23 12:10:18 UTC (rev 7287)
@@ -2621,7 +2621,7 @@
if opened:
fh.close()
-def griddata(x,y,z,xi,yi):
+def griddata(x,y,z,xi,yi,interp='nn'):
"""
``zi = griddata(x,y,z,xi,yi)`` fits a surface of the form *z* =
*f*(*x*, *y*) to the data in the (usually) nonuniformly spaced
@@ -2633,7 +2633,8 @@
A masked array is returned if any grid points are outside convex
hull defined by input data (no extrapolation is done).
- Uses natural neighbor interpolation based on Delaunay
+ If interp keyword is set to '`nn`' (default),
+ uses natural neighbor interpolation based on Delaunay
triangulation. By default, this algorithm is provided by the
:mod:`matplotlib.delaunay` package, written by Robert Kern. The
triangulation algorithm in this package is known to fail on some
@@ -2646,6 +2647,14 @@
algorithm, otherwise it will use the built-in
:mod:`matplotlib.delaunay` package.
+ If the interp keyword is set to '`linear`', then linear interpolation
+ is used instead of natural neighbor. In this case, the output grid
+ is assumed to be regular with a constant grid spacing in both the x and
+ y directions. For regular grids with nonconstant grid spacing, you
+ must use natural neighbor interpolation. Linear interpolation is only valid if
+ :mod:`matplotlib.delaunay` package is used - :mod:`mpl_tookits.natgrid`
+ only provides natural neighbor interpolation.
+
The natgrid matplotlib toolkit can be downloaded from
http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792
"""
@@ -2674,6 +2683,9 @@
y = y.compress(z.mask == False)
z = z.compressed()
if _use_natgrid: # use natgrid toolkit if available.
+ if interp != 'nn':
+ raise ValueError("only natural neighor interpolation"
+ " allowed when using natgrid toolkit in griddata.")
if xi.ndim == 2:
xi = xi[0,:]
yi = yi[:,0]
@@ -2701,8 +2713,17 @@
# triangulate data
tri = delaunay.Triangulation(x,y)
# interpolate data
- interp = tri.nn_interpolator(z)
- zo = interp(xi,yi)
+ if interp == 'nn':
+ interp = tri.nn_interpolator(z)
+ zo = interp(xi,yi)
+ elif interp == 'linear':
+ interp = tri.linear_interpolator(z)
+ zo = interp[yi.min():yi.max():complex(0,yi.shape[0]),
+ xi.min():xi.max():complex(0,xi.shape[1])]
+ else:
+ raise ValueError("interp keyword must be one of"
+ " 'linear' (for linear interpolation) or 'nn'"
+ " (for natural neighbor interpolation). Default is 'nn'.")
# mask points on grid outside convex hull of input data.
if np.any(np.isnan(zo)):
zo = np.ma.masked_where(np.isnan(zo),zo)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-22 13:58:27
|
Revision: 7286
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7286&view=rev
Author: evilguru
Date: 2009-07-22 13:58:18 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Really fix the PS alignment issues with mathtex.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_ps.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-22 13:54:55 UTC (rev 7285)
+++ branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-22 13:58:18 UTC (rev 7286)
@@ -755,7 +755,7 @@
# Glyphs
for ox, oy, info in m.glyphs:
- oy = m.height - m.depth - oy + info.offset
+ oy = (m.height + m.depth) - oy + info.offset
postscript_name = info.postscript_name
fontsize = info.fontsize
symbol_name = info.symbol_name
@@ -775,7 +775,7 @@
# Rects
for x1, y1, x2, y2 in m.rects:
- ps = "%f %f %f %f rectfill\n" % (x1, m.height - m.depth - y2, x2 - x1, y2 - y1)
+ ps = "%f %f %f %f rectfill\n" % (x1, (m.height + m.depth) - y2, x2 - x1, y2 - y1)
textwriter.write(ps)
self.set_color(*gc.get_rgb())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-22 13:54:59
|
Revision: 7285
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7285&view=rev
Author: evilguru
Date: 2009-07-22 13:54:55 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Rename _mathtext_data.py to _font_data.py and remove unused tables from it.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_ps.py
Added Paths:
-----------
branches/mathtex/lib/matplotlib/_font_data.py
Removed Paths:
-------------
branches/mathtex/lib/matplotlib/_mathtext_data.py
Copied: branches/mathtex/lib/matplotlib/_font_data.py (from rev 7265, branches/mathtex/lib/matplotlib/_mathtext_data.py)
===================================================================
--- branches/mathtex/lib/matplotlib/_font_data.py (rev 0)
+++ branches/mathtex/lib/matplotlib/_font_data.py 2009-07-22 13:54:55 UTC (rev 7285)
@@ -0,0 +1,1346 @@
+
+
+# Automatically generated.
+
+type12uni = {'uni24C8': 9416,
+'aring': 229,
+'uni22A0': 8864,
+'uni2292': 8850,
+'quotedblright': 8221,
+'uni03D2': 978,
+'uni2215': 8725,
+'uni03D0': 976,
+'V': 86,
+'dollar': 36,
+'uni301E': 12318,
+'uni03D5': 981,
+'four': 52,
+'uni25A0': 9632,
+'uni013C': 316,
+'uni013B': 315,
+'uni013E': 318,
+'Yacute': 221,
+'uni25DE': 9694,
+'uni013F': 319,
+'uni255A': 9562,
+'uni2606': 9734,
+'uni0180': 384,
+'uni22B7': 8887,
+'uni044F': 1103,
+'uni22B5': 8885,
+'uni22B4': 8884,
+'uni22AE': 8878,
+'uni22B2': 8882,
+'uni22B1': 8881,
+'uni22B0': 8880,
+'uni25CD': 9677,
+'uni03CE': 974,
+'uni03CD': 973,
+'uni03CC': 972,
+'uni03CB': 971,
+'uni03CA': 970,
+'uni22B8': 8888,
+'uni22C9': 8905,
+'uni0449': 1097,
+'uni20DD': 8413,
+'uni20DC': 8412,
+'uni20DB': 8411,
+'uni2231': 8753,
+'uni25CF': 9679,
+'uni306E': 12398,
+'uni03D1': 977,
+'uni01A1': 417,
+'uni20D7': 8407,
+'uni03D6': 982,
+'uni2233': 8755,
+'uni20D2': 8402,
+'uni20D1': 8401,
+'uni20D0': 8400,
+'P': 80,
+'uni22BE': 8894,
+'uni22BD': 8893,
+'uni22BC': 8892,
+'uni22BB': 8891,
+'underscore': 95,
+'uni03C8': 968,
+'uni03C7': 967,
+'uni0328': 808,
+'uni03C5': 965,
+'uni03C4': 964,
+'uni03C3': 963,
+'uni03C2': 962,
+'uni03C1': 961,
+'uni03C0': 960,
+'uni2010': 8208,
+'uni0130': 304,
+'uni0133': 307,
+'uni0132': 306,
+'uni0135': 309,
+'uni0134': 308,
+'uni0137': 311,
+'uni0136': 310,
+'uni0139': 313,
+'uni0138': 312,
+'uni2244': 8772,
+'uni229A': 8858,
+'uni2571': 9585,
+'uni0278': 632,
+'uni2239': 8761,
+'p': 112,
+'uni3019': 12313,
+'uni25CB': 9675,
+'uni03DB': 987,
+'uni03DC': 988,
+'uni03DA': 986,
+'uni03DF': 991,
+'uni03DD': 989,
+'uni013D': 317,
+'uni220A': 8714,
+'uni220C': 8716,
+'uni220B': 8715,
+'uni220E': 8718,
+'uni220D': 8717,
+'uni220F': 8719,
+'uni22CC': 8908,
+'Otilde': 213,
+'uni25E5': 9701,
+'uni2736': 10038,
+'perthousand': 8240,
+'zero': 48,
+'uni279B': 10139,
+'dotlessi': 305,
+'uni2279': 8825,
+'Scaron': 352,
+'zcaron': 382,
+'uni21D8': 8664,
+'egrave': 232,
+'uni0271': 625,
+'uni01AA': 426,
+'uni2332': 9010,
+'section': 167,
+'uni25E4': 9700,
+'Icircumflex': 206,
+'ntilde': 241,
+'uni041E': 1054,
+'ampersand': 38,
+'uni041C': 1052,
+'uni041A': 1050,
+'uni22AB': 8875,
+'uni21DB': 8667,
+'dotaccent': 729,
+'uni0416': 1046,
+'uni0417': 1047,
+'uni0414': 1044,
+'uni0415': 1045,
+'uni0412': 1042,
+'uni0413': 1043,
+'degree': 176,
+'uni0411': 1041,
+'K': 75,
+'uni25EB': 9707,
+'uni25EF': 9711,
+'uni0418': 1048,
+'uni0419': 1049,
+'uni2263': 8803,
+'uni226E': 8814,
+'uni2251': 8785,
+'uni02C8': 712,
+'uni2262': 8802,
+'acircumflex': 226,
+'uni22B3': 8883,
+'uni2261': 8801,
+'uni2394': 9108,
+'Aring': 197,
+'uni2260': 8800,
+'uni2254': 8788,
+'uni0436': 1078,
+'uni2267': 8807,
+'k': 107,
+'uni22C8': 8904,
+'uni226A': 8810,
+'uni231F': 8991,
+'smalltilde': 732,
+'uni2201': 8705,
+'uni2200': 8704,
+'uni2203': 8707,
+'uni02BD': 701,
+'uni2205': 8709,
+'uni2204': 8708,
+'Agrave': 192,
+'uni2206': 8710,
+'uni2209': 8713,
+'uni2208': 8712,
+'uni226D': 8813,
+'uni2264': 8804,
+'uni263D': 9789,
+'uni2258': 8792,
+'uni02D3': 723,
+'uni02D2': 722,
+'uni02D1': 721,
+'uni02D0': 720,
+'uni25E1': 9697,
+'divide': 247,
+'uni02D5': 725,
+'uni02D4': 724,
+'ocircumflex': 244,
+'uni2524': 9508,
+'uni043A': 1082,
+'uni24CC': 9420,
+'asciitilde': 126,
+'uni22B9': 8889,
+'uni24D2': 9426,
+'uni211E': 8478,
+'uni211D': 8477,
+'uni24DD': 9437,
+'uni211A': 8474,
+'uni211C': 8476,
+'uni211B': 8475,
+'uni25C6': 9670,
+'uni017F': 383,
+'uni017A': 378,
+'uni017C': 380,
+'uni017B': 379,
+'uni0346': 838,
+'uni22F1': 8945,
+'uni22F0': 8944,
+'two': 50,
+'uni2298': 8856,
+'uni24D1': 9425,
+'E': 69,
+'uni025D': 605,
+'scaron': 353,
+'uni2322': 8994,
+'uni25E3': 9699,
+'uni22BF': 8895,
+'F': 70,
+'uni0440': 1088,
+'uni255E': 9566,
+'uni22BA': 8890,
+'uni0175': 373,
+'uni0174': 372,
+'uni0177': 375,
+'uni0176': 374,
+'bracketleft': 91,
+'uni0170': 368,
+'uni0173': 371,
+'uni0172': 370,
+'asciicircum': 94,
+'uni0179': 377,
+'uni2590': 9616,
+'uni25E2': 9698,
+'uni2119': 8473,
+'uni2118': 8472,
+'uni25CC': 9676,
+'f': 102,
+'ordmasculine': 186,
+'uni229B': 8859,
+'uni22A1': 8865,
+'uni2111': 8465,
+'uni2110': 8464,
+'uni2113': 8467,
+'uni2112': 8466,
+'mu': 181,
+'uni2281': 8833,
+'paragraph': 182,
+'nine': 57,
+'uni25EC': 9708,
+'v': 118,
+'uni040C': 1036,
+'uni0113': 275,
+'uni22D0': 8912,
+'uni21CC': 8652,
+'uni21CB': 8651,
+'uni21CA': 8650,
+'uni22A5': 8869,
+'uni21CF': 8655,
+'uni21CE': 8654,
+'uni21CD': 8653,
+'guilsinglleft': 8249,
+'backslash': 92,
+'uni2284': 8836,
+'uni224E': 8782,
+'uni224D': 8781,
+'uni224F': 8783,
+'uni224A': 8778,
+'uni2287': 8839,
+'uni224C': 8780,
+'uni224B': 8779,
+'uni21BD': 8637,
+'uni2286': 8838,
+'uni030F': 783,
+'uni030D': 781,
+'uni030E': 782,
+'uni030B': 779,
+'uni030C': 780,
+'uni030A': 778,
+'uni026E': 622,
+'uni026D': 621,
+'six': 54,
+'uni026A': 618,
+'uni026C': 620,
+'uni25C1': 9665,
+'uni20D6': 8406,
+'uni045B': 1115,
+'uni045C': 1116,
+'uni256B': 9579,
+'uni045A': 1114,
+'uni045F': 1119,
+'uni045E': 1118,
+'A': 65,
+'uni2569': 9577,
+'uni0458': 1112,
+'uni0459': 1113,
+'uni0452': 1106,
+'uni0453': 1107,
+'uni2562': 9570,
+'uni0451': 1105,
+'uni0456': 1110,
+'uni0457': 1111,
+'uni0454': 1108,
+'uni0455': 1109,
+'icircumflex': 238,
+'uni0307': 775,
+'uni0304': 772,
+'uni0305': 773,
+'uni0269': 617,
+'uni0268': 616,
+'uni0300': 768,
+'uni0301': 769,
+'uni0265': 613,
+'uni0264': 612,
+'uni0267': 615,
+'uni0266': 614,
+'uni0261': 609,
+'uni0260': 608,
+'uni0263': 611,
+'uni0262': 610,
+'a': 97,
+'uni2207': 8711,
+'uni2247': 8775,
+'uni2246': 8774,
+'uni2241': 8769,
+'uni2240': 8768,
+'uni2243': 8771,
+'uni2242': 8770,
+'uni2312': 8978,
+'ogonek': 731,
+'uni2249': 8777,
+'uni2248': 8776,
+'uni3030': 12336,
+'q': 113,
+'uni21C2': 8642,
+'uni21C1': 8641,
+'uni21C0': 8640,
+'uni21C7': 8647,
+'uni21C6': 8646,
+'uni21C5': 8645,
+'uni21C4': 8644,
+'uni225F': 8799,
+'uni212C': 8492,
+'uni21C8': 8648,
+'uni2467': 9319,
+'oacute': 243,
+'uni028F': 655,
+'uni028E': 654,
+'uni026F': 623,
+'uni028C': 652,
+'uni028B': 651,
+'uni028A': 650,
+'uni2510': 9488,
+'ograve': 242,
+'edieresis': 235,
+'uni22CE': 8910,
+'uni22CF': 8911,
+'uni219F': 8607,
+'comma': 44,
+'uni22CA': 8906,
+'uni0429': 1065,
+'uni03C6': 966,
+'uni0427': 1063,
+'uni0426': 1062,
+'uni0425': 1061,
+'uni0424': 1060,
+'uni0423': 1059,
+'uni0422': 1058,
+'uni0421': 1057,
+'uni0420': 1056,
+'uni2465': 9317,
+'uni24D0': 9424,
+'uni2464': 9316,
+'uni0430': 1072,
+'otilde': 245,
+'uni2661': 9825,
+'uni24D6': 9430,
+'uni2466': 9318,
+'uni24D5': 9429,
+'uni219A': 8602,
+'uni2518': 9496,
+'uni22B6': 8886,
+'uni2461': 9313,
+'uni24D4': 9428,
+'uni2460': 9312,
+'uni24EA': 9450,
+'guillemotright': 187,
+'ecircumflex': 234,
+'greater': 62,
+'uni2011': 8209,
+'uacute': 250,
+'uni2462': 9314,
+'L': 76,
+'bullet': 8226,
+'uni02A4': 676,
+'uni02A7': 679,
+'cedilla': 184,
+'uni02A2': 674,
+'uni2015': 8213,
+'uni22C4': 8900,
+'uni22C5': 8901,
+'uni22AD': 8877,
+'uni22C7': 8903,
+'uni22C0': 8896,
+'uni2016': 8214,
+'uni22C2': 8898,
+'uni22C3': 8899,
+'uni24CF': 9423,
+'uni042F': 1071,
+'uni042E': 1070,
+'uni042D': 1069,
+'ydieresis': 255,
+'l': 108,
+'logicalnot': 172,
+'uni24CA': 9418,
+'uni0287': 647,
+'uni0286': 646,
+'uni0285': 645,
+'uni0284': 644,
+'uni0283': 643,
+'uni0282': 642,
+'uni0281': 641,
+'uni027C': 636,
+'uni2664': 9828,
+'exclamdown': 161,
+'uni25C4': 9668,
+'uni0289': 649,
+'uni0288': 648,
+'uni039A': 922,
+'endash': 8211,
+'uni2640': 9792,
+'uni20E4': 8420,
+'uni0473': 1139,
+'uni20E1': 8417,
+'uni2642': 9794,
+'uni03B8': 952,
+'uni03B9': 953,
+'agrave': 224,
+'uni03B4': 948,
+'uni03B5': 949,
+'uni03B6': 950,
+'uni03B7': 951,
+'uni03B0': 944,
+'uni03B1': 945,
+'uni03B2': 946,
+'uni03B3': 947,
+'uni2555': 9557,
+'Adieresis': 196,
+'germandbls': 223,
+'Odieresis': 214,
+'space': 32,
+'uni0126': 294,
+'uni0127': 295,
+'uni0124': 292,
+'uni0125': 293,
+'uni0122': 290,
+'uni0123': 291,
+'uni0120': 288,
+'uni0121': 289,
+'quoteright': 8217,
+'uni2560': 9568,
+'uni2556': 9558,
+'ucircumflex': 251,
+'uni2561': 9569,
+'uni2551': 9553,
+'uni25B2': 9650,
+'uni2550': 9552,
+'uni2563': 9571,
+'uni2553': 9555,
+'G': 71,
+'uni2564': 9572,
+'uni2552': 9554,
+'quoteleft': 8216,
+'uni2565': 9573,
+'uni2572': 9586,
+'uni2568': 9576,
+'uni2566': 9574,
+'W': 87,
+'uni214A': 8522,
+'uni012F': 303,
+'uni012D': 301,
+'uni012E': 302,
+'uni012B': 299,
+'uni012C': 300,
+'uni255C': 9564,
+'uni012A': 298,
+'uni2289': 8841,
+'Q': 81,
+'uni2320': 8992,
+'uni2321': 8993,
+'g': 103,
+'uni03BD': 957,
+'uni03BE': 958,
+'uni03BF': 959,
+'uni2282': 8834,
+'uni2285': 8837,
+'uni03BA': 954,
+'uni03BB': 955,
+'uni03BC': 956,
+'uni2128': 8488,
+'uni25B7': 9655,
+'w': 119,
+'uni0302': 770,
+'uni03DE': 990,
+'uni25DA': 9690,
+'uni0303': 771,
+'uni0463': 1123,
+'uni0462': 1122,
+'uni3018': 12312,
+'uni2514': 9492,
+'question': 63,
+'uni25B3': 9651,
+'uni24E1': 9441,
+'one': 49,
+'uni200A': 8202,
+'uni2278': 8824,
+'ring': 730,
+'uni0195': 405,
+'figuredash': 8210,
+'uni22EC': 8940,
+'uni0339': 825,
+'uni0338': 824,
+'uni0337': 823,
+'uni0336': 822,
+'uni0335': 821,
+'uni0333': 819,
+'uni0332': 818,
+'uni0331': 817,
+'uni0330': 816,
+'uni01C1': 449,
+'uni01C0': 448,
+'uni01C3': 451,
+'uni01C2': 450,
+'uni2353': 9043,
+'uni0308': 776,
+'uni2218': 8728,
+'uni2219': 8729,
+'uni2216': 8726,
+'uni2217': 8727,
+'uni2214': 8724,
+'uni0309': 777,
+'uni2609': 9737,
+'uni2213': 8723,
+'uni2210': 8720,
+'uni2211': 8721,
+'uni2245': 8773,
+'B': 66,
+'uni25D6': 9686,
+'iacute': 237,
+'uni02E6': 742,
+'uni02E7': 743,
+'uni02E8': 744,
+'uni02E9': 745,
+'uni221D': 8733,
+'uni221E': 8734,
+'Ydieresis': 376,
+'uni221C': 8732,
+'uni22D7': 8919,
+'uni221A': 8730,
+'R': 82,
+'uni24DC': 9436,
+'uni033F': 831,
+'uni033E': 830,
+'uni033C': 828,
+'uni033B': 827,
+'uni033A': 826,
+'b': 98,
+'uni228A': 8842,
+'uni22DB': 8923,
+'uni2554': 9556,
+'uni046B': 1131,
+'uni046A': 1130,
+'r': 114,
+'uni24DB': 9435,
+'Ccedilla': 199,
+'minus': 8722,
+'uni24DA': 9434,
+'uni03F0': 1008,
+'uni03F1': 1009,
+'uni20AC': 8364,
+'uni2276': 8822,
+'uni24C0': 9408,
+'uni0162': 354,
+'uni0163': 355,
+'uni011E': 286,
+'uni011D': 285,
+'uni011C': 284,
+'uni011B': 283,
+'uni0164': 356,
+'uni0165': 357,
+'Lslash': 321,
+'uni0168': 360,
+'uni0169': 361,
+'uni25C9': 9673,
+'uni02E5': 741,
+'uni21C3': 8643,
+'uni24C4': 9412,
+'uni24E2': 9442,
+'uni2277': 8823,
+'uni013A': 314,
+'uni2102': 8450,
+'Uacute': 218,
+'uni2317': 8983,
+'uni2107': 8455,
+'uni221F': 8735,
+'yacute': 253,
+'uni3012': 12306,
+'Ucircumflex': 219,
+'uni015D': 349,
+'quotedbl': 34,
+'uni25D9': 9689,
+'uni2280': 8832,
+'uni22AF': 8879,
+'onehalf': 189,
+'uni221B': 8731,
+'Thorn': 222,
+'uni2226': 8742,
+'M': 77,
+'uni25BA': 9658,
+'uni2463': 9315,
+'uni2336': 9014,
+'eight': 56,
+'uni2236': 8758,
+'multiply': 215,
+'uni210C': 8460,
+'uni210A': 8458,
+'uni21C9': 8649,
+'grave': 96,
+'uni210E': 8462,
+'uni0117': 279,
+'uni016C': 364,
+'uni0115': 277,
+'uni016A': 362,
+'uni016F': 367,
+'uni0112': 274,
+'uni016D': 365,
+'uni016E': 366,
+'Ocircumflex': 212,
+'uni2305': 8965,
+'m': 109,
+'uni24DF': 9439,
+'uni0119': 281,
+'uni0118': 280,
+'uni20A3': 8355,
+'uni20A4': 8356,
+'uni20A7': 8359,
+'uni2288': 8840,
+'uni24C3': 9411,
+'uni251C': 9500,
+'uni228D': 8845,
+'uni222F': 8751,
+'uni222E': 8750,
+'uni222D': 8749,
+'uni222C': 8748,
+'uni222B': 8747,
+'uni222A': 8746,
+'uni255B': 9563,
+'Ugrave': 217,
+'uni24DE': 9438,
+'guilsinglright': 8250,
+'uni250A': 9482,
+'Ntilde': 209,
+'uni0279': 633,
+'questiondown': 191,
+'uni256C': 9580,
+'Atilde': 195,
+'uni0272': 626,
+'uni0273': 627,
+'uni0270': 624,
+'ccedilla': 231,
+'uni0276': 630,
+'uni0277': 631,
+'uni0274': 628,
+'uni0275': 629,
+'uni2252': 8786,
+'uni041F': 1055,
+'uni2250': 8784,
+'Z': 90,
+'uni2256': 8790,
+'uni2257': 8791,
+'copyright': 169,
+'uni2255': 8789,
+'uni043D': 1085,
+'uni043E': 1086,
+'uni043F': 1087,
+'yen': 165,
+'uni041D': 1053,
+'uni043B': 1083,
+'uni043C': 1084,
+'uni21B0': 8624,
+'uni21B1': 8625,
+'uni21B2': 8626,
+'uni21B3': 8627,
+'uni21B4': 8628,
+'uni21B5': 8629,
+'uni21B6': 8630,
+'uni21B7': 8631,
+'uni21B8': 8632,
+'Eacute': 201,
+'uni2311': 8977,
+'uni2310': 8976,
+'uni228F': 8847,
+'uni25DB': 9691,
+'uni21BA': 8634,
+'uni21BB': 8635,
+'uni21BC': 8636,
+'uni2017': 8215,
+'uni21BE': 8638,
+'uni21BF': 8639,
+'uni231C': 8988,
+'H': 72,
+'uni0293': 659,
+'uni2202': 8706,
+'uni22A4': 8868,
+'uni231E': 8990,
+'uni2232': 8754,
+'uni225B': 8795,
+'uni225C': 8796,
+'uni24D9': 9433,
+'uni225A': 8794,
+'uni0438': 1080,
+'uni0439': 1081,
+'uni225D': 8797,
+'uni225E': 8798,
+'uni0434': 1076,
+'X': 88,
+'uni007F': 127,
+'uni0437': 1079,
+'Idieresis': 207,
+'uni0431': 1073,
+'uni0432': 1074,
+'uni0433': 1075,
+'uni22AC': 8876,
+'uni22CD': 8909,
+'uni25A3': 9635,
+'bar': 124,
+'uni24BB': 9403,
+'uni037E': 894,
+'uni027B': 635,
+'h': 104,
+'uni027A': 634,
+'uni027F': 639,
+'uni027D': 637,
+'uni027E': 638,
+'uni2227': 8743,
+'uni2004': 8196,
+'uni2225': 8741,
+'uni2224': 8740,
+'uni2223': 8739,
+'uni2222': 8738,
+'uni2221': 8737,
+'uni2220': 8736,
+'x': 120,
+'uni2323': 8995,
+'uni2559': 9561,
+'uni2558': 9560,
+'uni2229': 8745,
+'uni2228': 8744,
+'udieresis': 252,
+'uni029D': 669,
+'ordfeminine': 170,
+'uni22CB': 8907,
+'uni233D': 9021,
+'uni0428': 1064,
+'uni24C6': 9414,
+'uni22DD': 8925,
+'uni24C7': 9415,
+'uni015C': 348,
+'uni015B': 347,
+'uni015A': 346,
+'uni22AA': 8874,
+'uni015F': 351,
+'uni015E': 350,
+'braceleft': 123,
+'uni24C5': 9413,
+'uni0410': 1040,
+'uni03AA': 938,
+'uni24C2': 9410,
+'uni03AC': 940,
+'uni03AB': 939,
+'macron': 175,
+'uni03AD': 941,
+'uni03AF': 943,
+'uni0294': 660,
+'uni0295': 661,
+'uni0296': 662,
+'uni0297': 663,
+'uni0290': 656,
+'uni0291': 657,
+'uni0292': 658,
+'atilde': 227,
+'Acircumflex': 194,
+'uni2370': 9072,
+'uni24C1': 9409,
+'uni0298': 664,
+'uni0299': 665,
+'Oslash': 216,
+'uni029E': 670,
+'C': 67,
+'quotedblleft': 8220,
+'uni029B': 667,
+'uni029C': 668,
+'uni03A9': 937,
+'uni03A8': 936,
+'S': 83,
+'uni24C9': 9417,
+'uni03A1': 929,
+'uni03A0': 928,
+'exclam': 33,
+'uni03A5': 933,
+'uni03A4': 932,
+'uni03A7': 935,
+'Zcaron': 381,
+'uni2133': 8499,
+'uni2132': 8498,
+'uni0159': 345,
+'uni0158': 344,
+'uni2137': 8503,
+'uni2005': 8197,
+'uni2135': 8501,
+'uni2134': 8500,
+'uni02BA': 698,
+'uni2033': 8243,
+'uni0151': 337,
+'uni0150': 336,
+'uni0157': 343,
+'equal': 61,
+'uni0155': 341,
+'uni0154': 340,
+'s': 115,
+'uni233F': 9023,
+'eth': 240,
+'uni24BE': 9406,
+'uni21E9': 8681,
+'uni2060': 8288,
+'Egrave': 200,
+'uni255D': 9565,
+'uni24CD': 9421,
+'uni21E1': 8673,
+'uni21B9': 8633,
+'hyphen': 45,
+'uni01BE': 446,
+'uni01BB': 443,
+'period': 46,
+'igrave': 236,
+'uni01BA': 442,
+'uni2296': 8854,
+'uni2297': 8855,
+'uni2294': 8852,
+'uni2295': 8853,
+'colon': 58,
+'uni2293': 8851,
+'uni2290': 8848,
+'uni2291': 8849,
+'uni032D': 813,
+'uni032E': 814,
+'uni032F': 815,
+'uni032A': 810,
+'uni032B': 811,
+'uni032C': 812,
+'uni231D': 8989,
+'Ecircumflex': 202,
+'uni24D7': 9431,
+'uni25DD': 9693,
+'trademark': 8482,
+'Aacute': 193,
+'cent': 162,
+'uni0445': 1093,
+'uni266E': 9838,
+'uni266D': 9837,
+'uni266B': 9835,
+'uni03C9': 969,
+'uni2003': 8195,
+'uni2047': 8263,
+'lslash': 322,
+'uni03A6': 934,
+'uni2043': 8259,
+'uni250C': 9484,
+'uni2040': 8256,
+'uni255F': 9567,
+'uni24CB': 9419,
+'uni0472': 1138,
+'uni0446': 1094,
+'uni0474': 1140,
+'uni0475': 1141,
+'uni2508': 9480,
+'uni2660': 9824,
+'uni2506': 9478,
+'uni2502': 9474,
+'c': 99,
+'uni2500': 9472,
+'N': 78,
+'uni22A6': 8870,
+'uni21E7': 8679,
+'uni2130': 8496,
+'uni2002': 8194,
+'breve': 728,
+'uni0442': 1090,
+'Oacute': 211,
+'uni229F': 8863,
+'uni25C7': 9671,
+'uni229D': 8861,
+'uni229E': 8862,
+'guillemotleft': 171,
+'uni0329': 809,
+'uni24E5': 9445,
+'uni011F': 287,
+'uni0324': 804,
+'uni0325': 805,
+'uni0326': 806,
+'uni0327': 807,
+'uni0321': 801,
+'uni0322': 802,
+'n': 110,
+'uni2032': 8242,
+'uni2269': 8809,
+'uni2268': 8808,
+'uni0306': 774,
+'uni226B': 8811,
+'uni21EA': 8682,
+'uni0166': 358,
+'uni203B': 8251,
+'uni01B5': 437,
+'idieresis': 239,
+'uni02BC': 700,
+'uni01B0': 432,
+'braceright': 125,
+'seven': 55,
+'uni02BB': 699,
+'uni011A': 282,
+'uni29FB': 10747,
+'brokenbar': 166,
+'uni2036': 8246,
+'uni25C0': 9664,
+'uni0156': 342,
+'uni22D5': 8917,
+'uni0258': 600,
+'ugrave': 249,
+'uni22D6': 8918,
+'uni22D1': 8913,
+'uni2034': 8244,
+'uni22D3': 8915,
+'uni22D2': 8914,
+'uni203C': 8252,
+'uni223E': 8766,
+'uni02BF': 703,
+'uni22D9': 8921,
+'uni22D8': 8920,
+'uni25BD': 9661,
+'uni25BE': 9662,
+'uni25BF': 9663,
+'uni041B': 1051,
+'periodcentered': 183,
+'uni25BC': 9660,
+'uni019E': 414,
+'uni019B': 411,
+'uni019A': 410,
+'uni2007': 8199,
+'uni0391': 913,
+'uni0390': 912,
+'uni0393': 915,
+'uni0392': 914,
+'uni0395': 917,
+'uni0394': 916,
+'uni0397': 919,
+'uni0396': 918,
+'uni0399': 921,
+'uni0398': 920,
+'uni25C8': 9672,
+'uni2468': 9320,
+'sterling': 163,
+'uni22EB': 8939,
+'uni039C': 924,
+'uni039B': 923,
+'uni039E': 926,
+'uni039D': 925,
+'uni039F': 927,
+'I': 73,
+'uni03E1': 993,
+'uni03E0': 992,
+'uni2319': 8985,
+'uni228B': 8843,
+'uni25B5': 9653,
+'uni25B6': 9654,
+'uni22EA': 8938,
+'uni24B9': 9401,
+'uni044E': 1102,
+'uni0199': 409,
+'uni2266': 8806,
+'Y': 89,
+'uni22A2': 8866,
+'Eth': 208,
+'uni266F': 9839,
+'emdash': 8212,
+'uni263B': 9787,
+'uni24BD': 9405,
+'uni22DE': 8926,
+'uni0360': 864,
+'uni2557': 9559,
+'uni22DF': 8927,
+'uni22DA': 8922,
+'uni22DC': 8924,
+'uni0361': 865,
+'i': 105,
+'uni24BF': 9407,
+'uni0362': 866,
+'uni263E': 9790,
+'uni028D': 653,
+'uni2259': 8793,
+'uni0323': 803,
+'uni2265': 8805,
+'daggerdbl': 8225,
+'y': 121,
+'uni010A': 266,
+'plusminus': 177,
+'less': 60,
+'uni21AE': 8622,
+'uni0315': 789,
+'uni230B': 8971,
+'uni21AF': 8623,
+'uni21AA': 8618,
+'uni21AC': 8620,
+'uni21AB': 8619,
+'uni01FB': 507,
+'uni01FC': 508,
+'uni223A': 8762,
+'uni01FA': 506,
+'uni01FF': 511,
+'uni01FD': 509,
+'uni01FE': 510,
+'uni2567': 9575,
+'uni25E0': 9696,
+'uni0104': 260,
+'uni0105': 261,
+'uni0106': 262,
+'uni0107': 263,
+'uni0100': 256,
+'uni0101': 257,
+'uni0102': 258,
+'uni0103': 259,
+'uni2038': 8248,
+'uni2009': 8201,
+'uni2008': 8200,
+'uni0108': 264,
+'uni0109': 265,
+'uni02A1': 673,
+'uni223B': 8763,
+'uni226C': 8812,
+'uni25AC': 9644,
+'uni24D3': 9427,
+'uni21E0': 8672,
+'uni21E3': 8675,
+'Udieresis': 220,
+'uni21E2': 8674,
+'D': 68,
+'uni21E5': 8677,
+'uni2621': 9761,
+'uni21D1': 8657,
+'uni203E': 8254,
+'uni22C6': 8902,
+'uni21E4': 8676,
+'uni010D': 269,
+'uni010E': 270,
+'uni010F': 271,
+'five': 53,
+'T': 84,
+'uni010B': 267,
+'uni010C': 268,
+'uni2605': 9733,
+'uni2663': 9827,
+'uni21E6': 8678,
+'uni24B6': 9398,
+'uni22C1': 8897,
+'oslash': 248,
+'acute': 180,
+'uni01F0': 496,
+'d': 100,
+'OE': 338,
+'uni22E3': 8931,
+'Igrave': 204,
+'uni2308': 8968,
+'uni2309': 8969,
+'uni21A9': 8617,
+'t': 116,
+'uni2313': 8979,
+'uni03A3': 931,
+'uni21A4': 8612,
+'uni21A7': 8615,
+'uni21A6': 8614,
+'uni21A1': 8609,
+'uni21A0': 8608,
+'uni21A3': 8611,
+'uni21A2': 8610,
+'parenright': 41,
+'uni256A': 9578,
+'uni25DC': 9692,
+'uni24CE': 9422,
+'uni042C': 1068,
+'uni24E0': 9440,
+'uni042B': 1067,
+'uni0409': 1033,
+'uni0408': 1032,
+'uni24E7': 9447,
+'uni25B4': 9652,
+'uni042A': 1066,
+'uni228E': 8846,
+'uni0401': 1025,
+'adieresis': 228,
+'uni0403': 1027,
+'quotesingle': 39,
+'uni0405': 1029,
+'uni0404': 1028,
+'uni0407': 1031,
+'uni0406': 1030,
+'uni229C': 8860,
+'uni2306': 8966,
+'uni2253': 8787,
+'twodotenleader': 8229,
+'uni2131': 8497,
+'uni21DA': 8666,
+'uni2234': 8756,
+'uni2235': 8757,
+'uni01A5': 421,
+'uni2237': 8759,
+'uni2230': 8752,
+'uni02CC': 716,
+'slash': 47,
+'uni01A0': 416,
+'ellipsis': 8230,
+'uni2299': 8857,
+'uni2238': 8760,
+'numbersign': 35,
+'uni21A8': 8616,
+'uni223D': 8765,
+'uni01AF': 431,
+'uni223F': 8767,
+'uni01AD': 429,
+'uni01AB': 427,
+'odieresis': 246,
+'uni223C': 8764,
+'uni227D': 8829,
+'uni0280': 640,
+'O': 79,
+'uni227E': 8830,
+'uni21A5': 8613,
+'uni22D4': 8916,
+'uni25D4': 9684,
+'uni227F': 8831,
+'uni0435': 1077,
+'uni2302': 8962,
+'uni2669': 9833,
+'uni24E3': 9443,
+'uni2720': 10016,
+'uni22A8': 8872,
+'uni22A9': 8873,
+'uni040A': 1034,
+'uni22A7': 8871,
+'oe': 339,
+'uni040B': 1035,
+'uni040E': 1038,
+'uni22A3': 8867,
+'o': 111,
+'uni040F': 1039,
+'Edieresis': 203,
+'uni25D5': 9685,
+'plus': 43,
+'uni044D': 1101,
+'uni263C': 9788,
+'uni22E6': 8934,
+'uni2283': 8835,
+'uni258C': 9612,
+'uni219E': 8606,
+'uni24E4': 9444,
+'uni2136': 8502,
+'dagger': 8224,
+'uni24B7': 9399,
+'uni219B': 8603,
+'uni22E5': 8933,
+'three': 51,
+'uni210B': 8459,
+'uni2534': 9524,
+'uni24B8': 9400,
+'uni230A': 8970,
+'hungarumlaut': 733,
+'parenleft': 40,
+'uni0148': 328,
+'uni0149': 329,
+'uni2124': 8484,
+'uni2125': 8485,
+'uni2126': 8486,
+'uni2127': 8487,
+'uni0140': 320,
+'uni2129': 8489,
+'uni25C5': 9669,
+'uni0143': 323,
+'uni0144': 324,
+'uni0145': 325,
+'uni0146': 326,
+'uni0147': 327,
+'uni210D': 8461,
+'fraction': 8260,
+'uni2031': 8241,
+'uni2196': 8598,
+'uni2035': 8245,
+'uni24E6': 9446,
+'uni016B': 363,
+'uni24BA': 9402,
+'uni266A': 9834,
+'uni0116': 278,
+'uni2115': 8469,
+'registered': 174,
+'J': 74,
+'uni25DF': 9695,
+'uni25CE': 9678,
+'uni273D': 10045,
+'dieresis': 168,
+'uni212B': 8491,
+'uni0114': 276,
+'uni212D': 8493,
+'uni212E': 8494,
+'uni212F': 8495,
+'uni014A': 330,
+'uni014B': 331,
+'uni014C': 332,
+'uni014D': 333,
+'uni014E': 334,
+'uni014F': 335,
+'uni025E': 606,
+'uni24E8': 9448,
+'uni0111': 273,
+'uni24E9': 9449,
+'Ograve': 210,
+'j': 106,
+'uni2195': 8597,
+'uni2194': 8596,
+'uni2197': 8599,
+'uni2037': 8247,
+'uni2191': 8593,
+'uni2190': 8592,
+'uni2193': 8595,
+'uni2192': 8594,
+'uni29FA': 10746,
+'uni2713': 10003,
+'z': 122,
+'uni2199': 8601,
+'uni2198': 8600,
+'uni2667': 9831,
+'ae': 230,
+'uni0448': 1096,
+'semicolon': 59,
+'uni2666': 9830,
+'uni038F': 911,
+'uni0444': 1092,
+'uni0447': 1095,
+'uni038E': 910,
+'uni0441': 1089,
+'uni038C': 908,
+'uni0443': 1091,
+'uni038A': 906,
+'uni0250': 592,
+'uni0251': 593,
+'uni0252': 594,
+'uni0253': 595,
+'uni0254': 596,
+'at': 64,
+'uni0256': 598,
+'uni0257': 599,
+'uni0167': 359,
+'uni0259': 601,
+'uni228C': 8844,
+'uni2662': 9826,
+'uni0319': 793,
+'uni0318': 792,
+'uni24BC': 9404,
+'uni0402': 1026,
+'uni22EF': 8943,
+'Iacute': 205,
+'uni22ED': 8941,
+'uni22EE': 8942,
+'uni0311': 785,
+'uni0310': 784,
+'uni21E8': 8680,
+'uni0312': 786,
+'percent': 37,
+'uni0317': 791,
+'uni0316': 790,
+'uni21D6': 8662,
+'uni21D7': 8663,
+'uni21D4': 8660,
+'uni21D5': 8661,
+'uni21D2': 8658,
+'uni21D3': 8659,
+'uni21D0': 8656,
+'uni2138': 8504,
+'uni2270': 8816,
+'uni2271': 8817,
+'uni2272': 8818,
+'uni2273': 8819,
+'uni2274': 8820,
+'uni2275': 8821,
+'bracketright': 93,
+'uni21D9': 8665,
+'uni21DF': 8671,
+'uni21DD': 8669,
+'uni21DE': 8670,
+'AE': 198,
+'uni03AE': 942,
+'uni227A': 8826,
+'uni227B': 8827,
+'uni227C': 8828,
+'asterisk': 42,
+'aacute': 225,
+'uni226F': 8815,
+'uni22E2': 8930,
+'uni0386': 902,
+'uni22E0': 8928,
+'uni22E1': 8929,
+'U': 85,
+'uni22E7': 8935,
+'uni22E4': 8932,
+'uni0387': 903,
+'uni031A': 794,
+'eacute': 233,
+'uni22E8': 8936,
+'uni22E9': 8937,
+'uni24D8': 9432,
+'uni025A': 602,
+'uni025B': 603,
+'uni025C': 604,
+'e': 101,
+'uni0128': 296,
+'uni025F': 607,
+'uni2665': 9829,
+'thorn': 254,
+'uni0129': 297,
+'uni253C': 9532,
+'uni25D7': 9687,
+'u': 117,
+'uni0388': 904,
+'uni0389': 905,
+'uni0255': 597,
+'uni0171': 369,
+'uni0384': 900,
+'uni0385': 901,
+'uni044A': 1098,
+'uni252C': 9516,
+'uni044C': 1100,
+'uni044B': 1099}
+
+uni2type1 = dict([(v,k) for k,v in type12uni.items()])
\ No newline at end of file
Deleted: branches/mathtex/lib/matplotlib/_mathtext_data.py
===================================================================
--- branches/mathtex/lib/matplotlib/_mathtext_data.py 2009-07-22 13:49:38 UTC (rev 7284)
+++ branches/mathtex/lib/matplotlib/_mathtext_data.py 2009-07-22 13:54:55 UTC (rev 7285)
@@ -1,2524 +0,0 @@
-"""
-font data tables for truetype and afm computer modern fonts
-"""
-
-# this dict maps symbol names to fontnames, glyphindex. To get the
-# glyph index from the character code, you have to use get_charmap
-"""
-from matplotlib.ft2font import FT2Font
-font = FT2Font('/usr/local/share/matplotlib/cmr10.ttf')
-items = font.get_charmap().items()
-items.sort()
-
-for charcode, glyphind in items:
- print charcode, glyphind
-"""
-
-latex_to_bakoma = {
- r'\oint' : ('cmex10', 45),
- r'\bigodot' : ('cmex10', 50),
- r'\bigoplus' : ('cmex10', 55),
- r'\bigotimes' : ('cmex10', 59),
- r'\sum' : ('cmex10', 51),
- r'\prod' : ('cmex10', 24),
- r'\int' : ('cmex10', 56),
- r'\bigcup' : ('cmex10', 28),
- r'\bigcap' : ('cmex10', 60),
- r'\biguplus' : ('cmex10', 32),
- r'\bigwedge' : ('cmex10', 4),
- r'\bigvee' : ('cmex10', 37),
- r'\coprod' : ('cmex10', 42),
- r'\__sqrt__' : ('cmex10', 48),
- r'\leftbrace' : ('cmex10', 92),
- r'{' : ('cmex10', 92),
- r'\{' : ('cmex10', 92),
- r'\rightbrace' : ('cmex10', 130),
- r'}' : ('cmex10', 130),
- r'\}' : ('cmex10', 130),
- r'\leftangle' : ('cmex10', 97),
- r'\rightangle' : ('cmex10', 64),
- r'\langle' : ('cmex10', 97),
- r'\rangle' : ('cmex10', 64),
- r'\widehat' : ('cmex10', 15),
- r'\widetilde' : ('cmex10', 52),
-
- r'\omega' : ('cmmi10', 29),
- r'\varepsilon' : ('cmmi10', 20),
- r'\vartheta' : ('cmmi10', 22),
- r'\varrho' : ('cmmi10', 61),
- r'\varsigma' : ('cmmi10', 41),
- r'\varphi' : ('cmmi10', 6),
- r'\leftharpoonup' : ('cmmi10', 108),
- r'\leftharpoondown' : ('cmmi10', 68),
- r'\rightharpoonup' : ('cmmi10', 117),
- r'\rightharpoondown' : ('cmmi10', 77),
- r'\triangleright' : ('cmmi10', 130),
- r'\triangleleft' : ('cmmi10', 89),
- r'.' : ('cmmi10', 51),
- r',' : ('cmmi10', 44),
- r'<' : ('cmmi10', 99),
- r'/' : ('cmmi10', 98),
- r'>' : ('cmmi10', 107),
- r'\flat' : ('cmmi10', 131),
- r'\natural' : ('cmmi10', 90),
- r'\sharp' : ('cmmi10', 50),
- r'\smile' : ('cmmi10', 97),
- r'\frown' : ('cmmi10', 58),
- r'\ell' : ('cmmi10', 102),
- r'\imath' : ('cmmi10', 8),
- r'\jmath' : ('cmmi10', 65),
- r'\wp' : ('cmmi10', 14),
- r'\alpha' : ('cmmi10', 13),
- r'\beta' : ('cmmi10', 35),
- r'\gamma' : ('cmmi10', 24),
- r'\delta' : ('cmmi10', 38),
- r'\epsilon' : ('cmmi10', 54),
- r'\zeta' : ('cmmi10', 10),
- r'\eta' : ('cmmi10', 5),
- r'\theta' : ('cmmi10', 18),
- r'\iota' : ('cmmi10', 28),
- r'\lambda' : ('cmmi10', 9),
- r'\mu' : ('cmmi10', 32),
- r'\nu' : ('cmmi10', 34),
- r'\xi' : ('cmmi10', 7),
- r'\pi' : ('cmmi10', 36),
- r'\kappa' : ('cmmi10', 30),
- r'\rho' : ('cmmi10', 39),
- r'\sigma' : ('cmmi10', 21),
- r'\tau' : ('cmmi10', 43),
- r'\upsilon' : ('cmmi10', 25),
- r'\phi' : ('cmmi10', 42),
- r'\chi' : ('cmmi10', 17),
- r'\psi' : ('cmmi10', 31),
- r'|' : ('cmsy10', 47),
- r'\|' : ('cmsy10', 47),
- r'(' : ('cmr10', 119),
- r'\leftparen' : ('cmr10', 119),
- r'\rightparen' : ('cmr10', 68),
- r')' : ('cmr10', 68),
- r'+' : ('cmr10', 76),
- r'0' : ('cmr10', 40),
- r'1' : ('cmr10', 100),
- r'2' : ('cmr10', 49),
- r'3' : ('cmr10', 110),
- r'4' : ('cmr10', 59),
- r'5' : ('cmr10', 120),
- r'6' : ('cmr10', 69),
- r'7' : ('cmr10', 127),
- r'8' : ('cmr10', 77),
- r'9' : ('cmr10', 22),
- r':' : ('cmr10', 85),
- r';' : ('cmr10', 31),
- r'=' : ('cmr10', 41),
- r'\leftbracket' : ('cmr10', 62),
- r'[' : ('cmr10', 62),
- r'\rightbracket' : ('cmr10', 72),
- r']' : ('cmr10', 72),
- r'\%' : ('cmr10', 48),
- r'%' : ('cmr10', 48),
- r'\$' : ('cmr10', 99),
- r'@' : ('cmr10', 111),
- r'\_' : ('cmtt10', 79),
- r'\Gamma' : ('cmr10', 19),
- r'\Delta' : ('cmr10', 6),
- r'\Theta' : ('cmr10', 7),
- r'\Lambda' : ('cmr10', 14),
- r'\Xi' : ('cmr10', 3),
- r'\Pi' : ('cmr10', 17),
- r'\Sigma' : ('cmr10', 10),
- r'\Upsilon' : ('cmr10', 11),
- r'\Phi' : ('cmr10', 9),
- r'\Psi' : ('cmr10', 15),
- r'\Omega' : ('cmr10', 12),
-
- # these are mathml names, I think. I'm just using them for the
- # tex methods noted
- r'\circumflexaccent' : ('cmr10', 124), # for \hat
- r'\combiningbreve' : ('cmr10', 81), # for \breve
- r'\combiningoverline' : ('cmr10', 131), # for \bar
- r'\combininggraveaccent' : ('cmr10', 114), # for \grave
- r'\combiningacuteaccent' : ('cmr10', 63), # for \accute
- r'\combiningdiaeresis' : ('cmr10', 91), # for \ddot
- r'\combiningtilde' : ('cmr10', 75), # for \tilde
- r'\combiningrightarrowabove' : ('cmmi10', 110), # for \vec
- r'\combiningdotabove' : ('cmr10', 26), # for \dot
-
- r'\leftarrow' : ('cmsy10', 10),
- r'\uparrow' : ('cmsy10', 25),
- r'\downarrow' : ('cmsy10', 28),
- r'\leftrightarrow' : ('cmsy10', 24),
- r'\nearrow' : ('cmsy10', 99),
- r'\searrow' : ('cmsy10', 57),
- r'\simeq' : ('cmsy10', 108),
- r'\Leftarrow' : ('cmsy10', 104),
- r'\Rightarrow' : ('cmsy10', 112),
- r'\Uparrow' : ('cmsy10', 60),
- r'\Downarrow' : ('cmsy10', 68),
- r'\Leftrightarrow' : ('cmsy10', 51),
- r'\nwarrow' : ('cmsy10', 65),
- r'\swarrow' : ('cmsy10', 116),
- r'\propto' : ('cmsy10', 15),
- r'\prime' : ('cmsy10', 73),
- r"'" : ('cmsy10', 73),
- r'\infty' : ('cmsy10', 32),
- r'\in' : ('cmsy10', 59),
- r'\ni' : ('cmsy10', 122),
- r'\bigtriangleup' : ('cmsy10', 80),
- r'\bigtriangledown' : ('cmsy10', 132),
- r'\slash' : ('cmsy10', 87),
- r'\forall' : ('cmsy10', 21),
- r'\exists' : ('cmsy10', 5),
- r'\neg' : ('cmsy10', 20),
- r'\emptyset' : ('cmsy10', 33),
- r'\Re' : ('cmsy10', 95),
- r'\Im' : ('cmsy10', 52),
- r'\top' : ('cmsy10', 100),
- r'\bot' : ('cmsy10', 11),
- r'\aleph' : ('cmsy10', 26),
- r'\cup' : ('cmsy10', 6),
- r'\cap' : ('cmsy10', 19),
- r'\uplus' : ('cmsy10', 58),
- r'\wedge' : ('cmsy10', 43),
- r'\vee' : ('cmsy10', 96),
- r'\vdash' : ('cmsy10', 109),
- r'\dashv' : ('cmsy10', 66),
- r'\lfloor' : ('cmsy10', 117),
- r'\rfloor' : ('cmsy10', 74),
- r'\lceil' : ('cmsy10', 123),
- r'\rceil' : ('cmsy10', 81),
- r'\lbrace' : ('cmsy10', 92),
- r'\rbrace' : ('cmsy10', 105),
- r'\mid' : ('cmsy10', 47),
- r'\vert' : ('cmsy10', 47),
- r'\Vert' : ('cmsy10', 44),
- r'\updownarrow' : ('cmsy10', 94),
- r'\Updownarrow' : ('cmsy10', 53),
- r'\backslash' : ('cmsy10', 126),
- r'\wr' : ('cmsy10', 101),
- r'\nabla' : ('cmsy10', 110),
- r'\sqcup' : ('cmsy10', 67),
- r'\sqcap' : ('cmsy10', 118),
- r'\sqsubseteq' : ('cmsy10', 75),
- r'\sqsupseteq' : ('cmsy10', 124),
- r'\S' : ('cmsy10', 129),
- r'\dag' : ('cmsy10', 71),
- r'\ddag' : ('cmsy10', 127),
- r'\P' : ('cmsy10', 130),
- r'\clubsuit' : ('cmsy10', 18),
- r'\diamondsuit' : ('cmsy10', 34),
- r'\heartsuit' : ('cmsy10', 22),
- r'-' : ('cmsy10', 17),
- r'\cdot' : ('cmsy10', 78),
- r'\times' : ('cmsy10', 13),
- r'*' : ('cmsy10', 9),
- r'\ast' : ('cmsy10', 9),
- r'\div' : ('cmsy10', 31),
- r'\diamond' : ('cmsy10', 48),
- r'\pm' : ('cmsy10', 8),
- r'\mp' : ('cmsy10', 98),
- r'\oplus' : ('cmsy10', 16),
- r'\ominus' : ('cmsy10', 56),
- r'\otimes' : ('cmsy10', 30),
- r'\oslash' : ('cmsy10', 107),
- r'\odot' : ('cmsy10', 64),
- r'\bigcirc' : ('cmsy10', 115),
- r'\circ' : ('cmsy10', 72),
- r'\bullet' : ('cmsy10', 84),
- r'\asymp' : ('cmsy10', 121),
- r'\equiv' : ('cmsy10', 35),
- r'\subseteq' : ('cmsy10', 103),
- r'\supseteq' : ('cmsy10', 42),
- r'\leq' : ('cmsy10', 14),
- r'\geq' : ('cmsy10', 29),
- r'\preceq' : ('cmsy10', 79),
- r'\succeq' : ('cmsy10', 131),
- r'\sim' : ('cmsy10', 27),
- r'\approx' : ('cmsy10', 23),
- r'\subset' : ('cmsy10', 50),
- r'\supset' : ('cmsy10', 86),
- r'\ll' : ('cmsy10', 85),
- r'\gg' : ('cmsy10', 40),
- r'\prec' : ('cmsy10', 93),
- r'\succ' : ('cmsy10', 49),
- r'\rightarrow' : ('cmsy10', 12),
- r'\to' : ('cmsy10', 12),
- r'\spadesuit' : ('cmsy10', 7),
- }
-
-latex_to_cmex = {
- r'\__sqrt__' : 112,
- r'\bigcap' : 92,
- r'\bigcup' : 91,
- r'\bigodot' : 75,
- r'\bigoplus' : 77,
- r'\bigotimes' : 79,
- r'\biguplus' : 93,
- r'\bigvee' : 95,
- r'\bigwedge' : 94,
- r'\coprod' : 97,
- r'\int' : 90,
- r'\leftangle' : 173,
- r'\leftbrace' : 169,
- r'\oint' : 73,
- r'\prod' : 89,
- r'\rightangle' : 174,
- r'\rightbrace' : 170,
- r'\sum' : 88,
- r'\widehat' : 98,
- r'\widetilde' : 101,
-}
-
-latex_to_standard = {
- r'\cong' : ('psyr', 64),
- r'\Delta' : ('psyr', 68),
- r'\Phi' : ('psyr', 70),
- r'\Gamma' : ('psyr', 89),
- r'\alpha' : ('psyr', 97),
- r'\beta' : ('psyr', 98),
- r'\chi' : ('psyr', 99),
- r'\delta' : ('psyr', 100),
- r'\varepsilon' : ('psyr', 101),
- r'\phi' : ('psyr', 102),
- r'\gamma' : ('psyr', 103),
- r'\eta' : ('psyr', 104),
- r'\iota' : ('psyr', 105),
- r'\varpsi' : ('psyr', 106),
- r'\kappa' : ('psyr', 108),
- r'\nu' : ('psyr', 110),
- r'\pi' : ('psyr', 112),
- r'\theta' : ('psyr', 113),
- r'\rho' : ('psyr', 114),
- r'\sigma' : ('psyr', 115),
- r'\tau' : ('psyr', 116),
- r'\upsilon' : ('psyr', 117),
- r'\varpi' : ('psyr', 118),
- r'\omega' : ('psyr', 119),
- r'\xi' : ('psyr', 120),
- r'\psi' : ('psyr', 121),
- r'\zeta' : ('psyr', 122),
- r'\sim' : ('psyr', 126),
- r'\leq' : ('psyr', 163),
- r'\infty' : ('psyr', 165),
- r'\clubsuit' : ('psyr', 167),
- r'\diamondsuit' : ('psyr', 168),
- r'\heartsuit' : ('psyr', 169),
- r'\spadesuit' : ('psyr', 170),
- r'\leftrightarrow' : ('psyr', 171),
- r'\leftarrow' : ('psyr', 172),
- r'\uparrow' : ('psyr', 173),
- r'\rightarrow' : ('psyr', 174),
- r'\downarrow' : ('psyr', 175),
- r'\pm' : ('psyr', 176),
- r'\geq' : ('psyr', 179),
- r'\times' : ('psyr', 180),
- r'\propto' : ('psyr', 181),
- r'\partial' : ('psyr', 182),
- r'\bullet' : ('psyr', 183),
- r'\div' : ('psyr', 184),
- r'\neq' : ('psyr', 185),
- r'\equiv' : ('psyr', 186),
- r'\approx' : ('psyr', 187),
- r'\ldots' : ('psyr', 188),
- r'\aleph' : ('psyr', 192),
- r'\Im' : ('psyr', 193),
- r'\Re' : ('psyr', 194),
- r'\wp' : ('psyr', 195),
- r'\otimes' : ('psyr', 196),
- r'\oplus' : ('psyr', 197),
- r'\oslash' : ('psyr', 198),
- r'\cap' : ('psyr', 199),
- r'\cup' : ('psyr', 200),
- r'\supset' : ('psyr', 201),
- r'\supseteq' : ('psyr', 202),
- r'\subset' : ('psyr', 204),
- r'\subseteq' : ('psyr', 205),
- r'\in' : ('psyr', 206),
- r'\notin' : ('psyr', 207),
- r'\angle' : ('psyr', 208),
- r'\nabla' : ('psyr', 209),
- r'\textregistered' : ('psyr', 210),
- r'\copyright' : ('psyr', 211),
- r'\texttrademark' : ('psyr', 212),
- r'\Pi' : ('psyr', 213),
- r'\prod' : ('psyr', 213),
- r'\surd' : ('psyr', 214),
- r'\__sqrt__' : ('psyr', 214),
- r'\cdot' : ('psyr', 215),
- r'\urcorner' : ('psyr', 216),
- r'\vee' : ('psyr', 217),
- r'\wedge' : ('psyr', 218),
- r'\Leftrightarrow' : ('psyr', 219),
- r'\Leftarrow' : ('psyr', 220),
- r'\Uparrow' : ('psyr', 221),
- r'\Rightarrow' : ('psyr', 222),
- r'\Downarrow' : ('psyr', 223),
- r'\Diamond' : ('psyr', 224),
- r'\langle' : ('psyr', 225),
- r'\Sigma' : ('psyr', 229),
- r'\sum' : ('psyr', 229),
- r'\forall' : ('psyr', 34),
- r'\exists' : ('psyr', 36),
- r'\lceil' : ('psyr', 233),
- r'\lbrace' : ('psyr', 123),
- r'\Psi' : ('psyr', 89),
- r'\bot' : ('psyr', 0136),
- r'\Omega' : ('psyr', 0127),
- r'\leftbracket' : ('psyr', 0133),
- r'\rightbracket' : ('psyr', 0135),
- r'\leftbrace' : ('psyr', 123),
- r'\leftparen' : ('psyr', 050),
- r'\prime' : ('psyr', 0242),
- r'\sharp' : ('psyr', 043),
- r'\slash' : ('psyr', 057),
- r'\Lamda' : ('psyr', 0114),
- r'\neg' : ('psyr', 0330),
- r'\Upsilon' : ('psyr', 0241),
- r'\rightbrace' : ('psyr', 0175),
- r'\rfloor' : ('psyr', 0373),
- r'\lambda' : ('psyr', 0154),
- r'\to' : ('psyr', 0256),
- r'\Xi' : ('psyr', 0130),
- r'\emptyset' : ('psyr', 0306),
- r'\lfloor' : ('psyr', 0353),
- r'\rightparen' : ('psyr', 051),
- r'\rceil' : ('psyr', 0371),
- r'\ni' : ('psyr', 047),
- r'\epsilon' : ('psyr', 0145),
- r'\Theta' : ('psyr', 0121),
- r'\langle' : ('psyr', 0341),
- r'\leftangle' : ('psyr', 0341),
- r'\rangle' : ('psyr', 0361),
- r'\rightangle' : ('psyr', 0361),
- r'\rbrace' : ('psyr', 0175),
- r'\circ' : ('psyr', 0260),
- r'\diamond' : ('psyr', 0340),
- r'\mu' : ('psyr', 0155),
- r'\mid' : ('psyr', 0352),
- r'\imath' : ('pncri8a', 105),
- r'\%' : ('pncr8a', 37),
- r'\$' : ('pncr8a', 36),
- r'\{' : ('pncr8a', 123),
- r'\}' : ('pncr8a', 125),
- r'\backslash' : ('pncr8a', 92),
- r'\ast' : ('pncr8a', 42),
-
- r'\circumflexaccent' : ('pncri8a', 124), # for \hat
- r'\combiningbreve' : ('pncri8a', 81), # for \breve
- r'\combininggraveaccent' : ('pncri8a', 114), # for \grave
- r'\combiningacuteaccent' : ('pncri8a', 63), # for \accute
- r'\combiningdiaeresis' : ('pncri8a', 91), # for \ddot
- r'\combiningtilde' : ('pncri8a', 75), # for \tilde
- r'\combiningrightarrowabove' : ('pncri8a', 110), # for \vec
- r'\combiningdotabove' : ('pncri8a', 26), # for \dot
-}
-
-# Automatically generated.
-
-type12uni = {'uni24C8': 9416,
-'aring': 229,
-'uni22A0': 8864,
-'uni2292': 8850,
-'quotedblright': 8221,
-'uni03D2': 978,
-'uni2215': 8725,
-'uni03D0': 976,
-'V': 86,
-'dollar': 36,
-'uni301E': 12318,
-'uni03D5': 981,
-'four': 52,
-'uni25A0': 9632,
-'uni013C': 316,
-'uni013B': 315,
-'uni013E': 318,
-'Yacute': 221,
-'uni25DE': 9694,
-'uni013F': 319,
-'uni255A': 9562,
-'uni2606': 9734,
-'uni0180': 384,
-'uni22B7': 8887,
-'uni044F': 1103,
-'uni22B5': 8885,
-'uni22B4': 8884,
-'uni22AE': 8878,
-'uni22B2': 8882,
-'uni22B1': 8881,
-'uni22B0': 8880,
-'uni25CD': 9677,
-'uni03CE': 974,
-'uni03CD': 973,
-'uni03CC': 972,
-'uni03CB': 971,
-'uni03CA': 970,
-'uni22B8': 8888,
-'uni22C9': 8905,
-'uni0449': 1097,
-'uni20DD': 8413,
-'uni20DC': 8412,
-'uni20DB': 8411,
-'uni2231': 8753,
-'uni25CF': 9679,
-'uni306E': 12398,
-'uni03D1': 977,
-'uni01A1': 417,
-'uni20D7': 8407,
-'uni03D6': 982,
-'uni2233': 8755,
-'uni20D2': 8402,
-'uni20D1': 8401,
-'uni20D0': 8400,
-'P': 80,
-'uni22BE': 8894,
-'uni22BD': 8893,
-'uni22BC': 8892,
-'uni22BB': 8891,
-'underscore': 95,
-'uni03C8': 968,
-'uni03C7': 967,
-'uni0328': 808,
-'uni03C5': 965,
-'uni03C4': 964,
-'uni03C3': 963,
-'uni03C2': 962,
-'uni03C1': 961,
-'uni03C0': 960,
-'uni2010': 8208,
-'uni0130': 304,
-'uni0133': 307,
-'uni0132': 306,
-'uni0135': 309,
-'uni0134': 308,
-'uni0137': 311,
-'uni0136': 310,
-'uni0139': 313,
-'uni0138': 312,
-'uni2244': 8772,
-'uni229A': 8858,
-'uni2571': 9585,
-'uni0278': 632,
-'uni2239': 8761,
-'p': 112,
-'uni3019': 12313,
-'uni25CB': 9675,
-'uni03DB': 987,
-'uni03DC': 988,
-'uni03DA': 986,
-'uni03DF': 991,
-'uni03DD': 989,
-'uni013D': 317,
-'uni220A': 8714,
-'uni220C': 8716,
-'uni220B': 8715,
-'uni220E': 8718,
-'uni220D': 8717,
-'uni220F': 8719,
-'uni22CC': 8908,
-'Otilde': 213,
-'uni25E5': 9701,
-'uni2736': 10038,
-'perthousand': 8240,
-'zero': 48,
-'uni279B': 10139,
-'dotlessi': 305,
-'uni2279': 8825,
-'Scaron': 352,
-'zcaron': 382,
-'uni21D8': 8664,
-'egrave': 232,
-'uni0271': 625,
-'uni01AA': 426,
-'uni2332': 9010,
-'section': 167,
-'uni25E4': 9700,
-'Icircumflex': 206,
-'ntilde': 241,
-'uni041E': 1054,
-'ampersand': 38,
-'uni041C': 1052,
-'uni041A': 1050,
-'uni22AB': 8875,
-'uni21DB': 8667,
-'dotaccent': 729,
-'uni0416': 1046,
-'uni0417': 1047,
-'uni0414': 1044,
-'uni0415': 1045,
-'uni0412': 1042,
-'uni0413': 1043,
-'degree': 176,
-'uni0411': 1041,
-'K': 75,
-'uni25EB': 9707,
-'uni25EF': 9711,
-'uni0418': 1048,
-'uni0419': 1049,
-'uni2263': 8803,
-'uni226E': 8814,
-'uni2251': 8785,
-'uni02C8': 712,
-'uni2262': 8802,
-'acircumflex': 226,
-'uni22B3': 8883,
-'uni2261': 8801,
-'uni2394': 9108,
-'Aring': 197,
-'uni2260': 8800,
-'uni2254': 8788,
-'uni0436': 1078,
-'uni2267': 8807,
-'k': 107,
-'uni22C8': 8904,
-'uni226A': 8810,
-'uni231F': 8991,
-'smalltilde': 732,
-'uni2201': 8705,
-'uni2200': 8704,
-'uni2203': 8707,
-'uni02BD': 701,
-'uni2205': 8709,
-'uni2204': 8708,
-'Agrave': 192,
-'uni2206': 8710,
-'uni2209': 8713,
-'uni2208': 8712,
-'uni226D': 8813,
-'uni2264': 8804,
-'uni263D': 9789,
-'uni2258': 8792,
-'uni02D3': 723,
-'uni02D2': 722,
-'uni02D1': 721,
-'uni02D0': 720,
-'uni25E1': 9697,
-'divide': 247,
-'uni02D5': 725,
-'uni02D4': 724,
-'ocircumflex': 244,
-'uni2524': 9508,
-'uni043A': 1082,
-'uni24CC': 9420,
-'asciitilde': 126,
-'uni22B9': 8889,
-'uni24D2': 9426,
-'uni211E': 8478,
-'uni211D': 8477,
-'uni24DD': 9437,
-'uni211A': 8474,
-'uni211C': 8476,
-'uni211B': 8475,
-'uni25C6': 9670,
-'uni017F': 383,
-'uni017A': 378,
-'uni017C': 380,
-'uni017B': 379,
-'uni0346': 838,
-'uni22F1': 8945,
-'uni22F0': 8944,
-'two': 50,
-'uni2298': 8856,
-'uni24D1': 9425,
-'E': 69,
-'uni025D': 605,
-'scaron': 353,
-'uni2322': 8994,
-'uni25E3': 9699,
-'uni22BF': 8895,
-'F': 70,
-'uni0440': 1088,
-'uni255E': 9566,
-'uni22BA': 8890,
-'uni0175': 373,
-'uni0174': 372,
-'uni0177': 375,
-'uni0176': 374,
-'bracketleft': 91,
-'uni0170': 368,
-'uni0173': 371,
-'uni0172': 370,
-'asciicircum': 94,
-'uni0179': 377,
-'uni2590': 9616,
-'uni25E2': 9698,
-'uni2119': 8473,
-'uni2118': 8472,
-'uni25CC': 9676,
-'f': 102,
-'ordmasculine': 186,
-'uni229B': 8859,
-'uni22A1': 8865,
-'uni2111': 8465,
-'uni2110': 8464,
-'uni2113': 8467,
-'uni2112': 8466,
-'mu': 181,
-'uni2281': 8833,
-'paragraph': 182,
-'nine': 57,
-'uni25EC': 9708,
-'v': 118,
-'uni040C': 1036,
-'uni0113': 275,
-'uni22D0': 8912,
-'uni21CC': 8652,
-'uni21CB': 8651,
-'uni21CA': 8650,
-'uni22A5': 8869,
-'uni21CF': 8655,
-'uni21CE': 8654,
-'uni21CD': 8653,
-'guilsinglleft': 8249,
-'backslash': 92,
-'uni2284': 8836,
-'uni224E': 8782,
-'uni224D': 8781,
-'uni224F': 8783,
-'uni224A': 8778,
-'uni2287': 8839,
-'uni224C': 8780,
-'uni224B': 8779,
-'uni21BD': 8637,
-'uni2286': 8838,
-'uni030F': 783,
-'uni030D': 781,
-'uni030E': 782,
-'uni030B': 779,
-'uni030C': 780,
-'uni030A': 778,
-'uni026E': 622,
-'uni026D': 621,
-'six': 54,
-'uni026A': 618,
-'uni026C': 620,
-'uni25C1': 9665,
-'uni20D6': 8406,
-'uni045B': 1115,
-'uni045C': 1116,
-'uni256B': 9579,
-'uni045A': 1114,
-'uni045F': 1119,
-'uni045E': 1118,
-'A': 65,
-'uni2569': 9577,
-'uni0458': 1112,
-'uni0459': 1113,
-'uni0452': 1106,
-'uni0453': 1107,
-'uni2562': 9570,
-'uni0451': 1105,
-'uni0456': 1110,
-'uni0457': 1111,
-'uni0454': 1108,
-'uni0455': 1109,
-'icircumflex': 238,
-'uni0307': 775,
-'uni0304': 772,
-'uni0305': 773,
-'uni0269': 617,
-'uni0268': 616,
-'uni0300': 768,
-'uni0301': 769,
-'uni0265': 613,
-'uni0264': 612,
-'uni0267': 615,
-'uni0266': 614,
-'uni0261': 609,
-'uni0260': 608,
-'uni0263': 611,
-'uni0262': 610,
-'a': 97,
-'uni2207': 8711,
-'uni2247': 8775,
-'uni2246': 8774,
-'uni2241': 8769,
-'uni2240': 8768,
-'uni2243': 8771,
-'uni2242': 8770,
-'uni2312': 8978,
-'ogonek': 731,
-'uni2249': 8777,
-'uni2248': 8776,
-'uni3030': 12336,
-'q': 113,
-'uni21C2': 8642,
-'uni21C1': 8641,
-'uni21C0': 8640,
-'uni21C7': 8647,
-'uni21C6': 8646,
-'uni21C5': 8645,
-'uni21C4': 8644,
-'uni225F': 8799,
-'uni212C': 8492,
-'uni21C8': 8648,
-'uni2467': 9319,
-'oacute': 243,
-'uni028F': 655,
-'uni028E': 654,
-'uni026F': 623,
-'uni028C': 652,
-'uni028B': 651,
-'uni028A': 650,
-'uni2510': 9488,
-'ograve': 242,
-'edieresis': 235,
-'uni22CE': 8910,
-'uni22CF': 8911,
-'uni219F': 8607,
-'comma': 44,
-'uni22CA': 8906,
-'uni0429': 1065,
-'uni03C6': 966,
-'uni0427': 1063,
-'uni0426': 1062,
-'uni0425': 1061,
-'uni0424': 1060,
-'uni0423': 1059,
-'uni0422': 1058,
-'uni0421': 1057,
-'uni0420': 1056,
-'uni2465': 9317,
-'uni24D0': 9424,
-'uni2464': 9316,
-'uni0430': 1072,
-'otilde': 245,
-'uni2661': 9825,
-'uni24D6': 9430,
-'uni2466': 9318,
-'uni24D5': 9429,
-'uni219A': 8602,
-'uni2518': 9496,
-'uni22B6': 8886,
-'uni2461': 9313,
-'uni24D4': 9428,
-'uni2460': 9312,
-'uni24EA': 9450,
-'guillemotright': 187,
-'ecircumflex': 234,
-'greater': 62,
-'uni2011': 8209,
-'uacute': 250,
-'uni2462': 9314,
-'L': 76,
-'bullet': 8226,
-'uni02A4': 676,
-'uni02A7': 679,
-'cedilla': 184,
-'uni02A2': 674,
-'uni2015': 8213,
-'uni22C4': 8900,
-'uni22C5': 8901,
-'uni22AD': 8877,
-'uni22C7': 8903,
-'uni22C0': 8896,
-'uni2016': 8214,
-'uni22C2': 8898,
-'uni22C3': 8899,
-'uni24CF': 9423,
-'uni042F': 1071,
-'uni042E': 1070,
-'uni042D': 1069,
-'ydieresis': 255,
-'l': 108,
-'logicalnot': 172,
-'uni24CA': 9418,
-'uni0287': 647,
-'uni0286': 646,
-'uni0285': 645,
-'uni0284': 644,
-'uni0283': 643,
-'uni0282': 642,
-'uni0281': 641,
-'uni027C': 636,
-'uni2664': 9828,
-'exclamdown': 161,
-'uni25C4': 9668,
-'uni0289': 649,
-'uni0288': 648,
-'uni039A': 922,
-'endash': 8211,
-'uni2640': 9792,
-'uni20E4': 8420,
-'uni0473': 1139,
-'uni20E1': 8417,
-'uni2642': 9794,
-'uni03B8': 952,
-'uni03B9': 953,
-'agrave': 224,
-'uni03B4': 948,
-'uni03B5': 949,
-'uni03B6': 950,
-'uni03B7': 951,
-'uni03B0': 944,
-'uni03B1': 945,
-'uni03B2': 946,
-'uni03B3': 947,
-'uni2555': 9557,
-'Adieresis': 196,
-'germandbls': 223,
-'Odieresis': 214,
-'space': 32,
-'uni0126': 294,
-'uni0127': 295,
-'uni0124': 292,
-'uni0125': 293,
-'uni0122': 290,
-'uni0123': 291,
-'uni0120': 288,
-'uni0121': 289,
-'quoteright': 8217,
-'uni2560': 9568,
-'uni2556': 9558,
-'ucircumflex': 251,
-'uni2561': 9569,
-'uni2551': 9553,
-'uni25B2': 9650,
-'uni2550': 9552,
-'uni2563': 9571,
-'uni2553': 9555,
-'G': 71,
-'uni2564': 9572,
-'uni2552': 9554,
-'quoteleft': 8216,
-'uni2565': 9573,
-'uni2572': 9586,
-'uni2568': 9576,
-'uni2566': 9574,
-'W': 87,
-'uni214A': 8522,
-'uni012F': 303,
-'uni012D': 301,
-'uni012E': 302,
-'uni012B': 299,
-'uni012C': 300,
-'uni255C': 9564,
-'uni012A': 298,
-'uni2289': 8841,
-'Q': 81,
-'uni2320': 8992,
-'uni2321': 8993,
-'g': 103,
-'uni03BD': 957,
-'uni03BE': 958,
-'uni03BF': 959,
-'uni2282': 8834,
-'uni2285': 8837,
-'uni03BA': 954,
-'uni03BB': 955,
-'uni03BC': 956,
-'uni2128': 8488,
-'uni25B7': 9655,
-'w': 119,
-'uni0302': 770,
-'uni03DE': 990,
-'uni25DA': 9690,
-'uni0303': 771,
-'uni0463': 1123,
-'uni0462': 1122,
-'uni3018': 12312,
-'uni2514': 9492,
-'question': 63,
-'uni25B3': 9651,
-'uni24E1': 9441,
-'one': 49,
-'uni200A': 8202,
-'uni2278': 8824,
-'ring': 730,
-'uni0195': 405,
-'figuredash': 8210,
-'uni22EC': 8940,
-'uni0339': 825,
-'uni0338': 824,
-'uni0337': 823,
-'uni0336': 822,
-'uni0335': 821,
-'uni0333': 819,
-'uni0332': 818,
-'uni0331': 817,
-'uni0330': 816,
-'uni01C1': 449,
-'uni01C0': 448,
-'uni01C3': 451,
-'uni01C2': 450,
-'uni2353': 9043,
-'uni0308': 776,
-'uni2218': 8728,
-'uni2219': 8729,
-'uni2216': 8726,
-'uni2217': 8727,
-'uni2214': 8724,
-'uni0309': 777,
-'uni2609': 9737,
-'uni2213': 8723,
-'uni2210': 8720,
-'uni2211': 8721,
-'uni2245': 8773,
-'B': 66,
-'uni25D6': 9686,
-'iacute': 237,
-'uni02E6': 742,
-'uni02E7': 743,
-'uni02E8': 744,
-'uni02E9': 745,
-'uni221D': 8733,
-'uni221E': 8734,
-'Ydieresis': 376,
-'uni221C': 8732,
-'uni22D7': 8919,
-'uni221A': 8730,
-'R': 82,
-'uni24DC': 9436,
-'uni033F': 831,
-'uni033E': 830,
-'uni033C': 828,
-'uni033B': 827,
-'uni033A': 826,
-'b': 98,
-'uni228A': 8842,
-'uni22DB': 8923,
-'uni2554': 9556,
-'uni046B': 1131,
-'uni046A': 1130,
-'r': 114,
-'uni24DB': 9435,
-'Ccedilla': 199,
-'minus': 8722,
-'uni24DA': 9434,
-'uni03F0': 1008,
-'uni03F1': 1009,
-'uni20AC': 8364,
-'uni2276': 8822,
-'uni24C0': 9408,
-'uni0162': 354,
-'uni0163': 355,
-'uni011E': 286,
-'uni011D': 285,
-'uni011C': 284,
-'uni011B': 283,
-'uni0164': 356,
-'uni0165': 357,
-'Lslash': 321,
-'uni0168': 360,
-'uni0169': 361,
-'uni25C9': 9673,
-'uni02E5': 741,
-'uni21C3': 8643,
-'uni24C4': 9412,
-'uni24E2': 9442,
-'uni2277': 8823,
-'uni013A': 314,
-'uni2102': 8450,
-'Uacute': 218,
-'uni2317': 8983,
-'uni2107': 8455,
-'uni221F': 8735,
-'yacute': 253,
-'uni3012': 12306,
-'Ucircumflex': 219,
-'uni015D': 349,
-'quotedbl': 34,
-'uni25D9': 9689,
-'uni2280': 8832,
-'uni22AF': 8879,
-'onehalf': 189,
-'uni221B': 8731,
-'Thorn': 222,
-'uni2226': 8742,
-'M': 77,
-'uni25BA': 9658,
-'uni2463': 9315,
-'uni2336': 9014,
-'eight': 56,
-'uni2236': 8758,
-'multiply': 215,
-'uni210C': 8460,
-'uni210A': 8458,
-'uni21C9': 8649,
-'grave': 96,
-'uni210E': 8462,
-'uni0117': 279,
-'uni016C': 364,
-'uni0115': 277,
-'uni016A': 362,
-'uni016F': 367,
-'uni0112': 274,
-'uni016D': 365,
-'uni016E': 366,
-'Ocircumflex': 212,
-'uni2305': 8965,
-'m': 109,
-'uni24DF': 9439,
-'uni0119': 281,
-'uni0118': 280,
-'uni20A3': 8355,
-'uni20A4': 8356,
-'uni20A7': 8359,
-'uni2288': 8840,
-'uni24C3': 9411,
-'uni251C': 9500,
-'uni228D': 8845,
-'uni222F': 8751,
-'uni222E': 8750,
-'uni222D': 8749,
-'uni222C': 8748,
-'uni222B': 8747,
-'uni222A': 8746,
-'uni255B': 9563,
-'Ugrave': 217,
-'uni24DE': 9438,
-'guilsinglright': 8250,
-'uni250A': 9482,
-'Ntilde': 209,
-'uni0279': 633,
-'questiondown': 191,
-'uni256C': 9580,
-'Atilde': 195,
-'uni0272': 626,
-'uni0273': 627,
-'uni0270': 624,
-'ccedilla': 231,
-'uni0276': 630,
-'uni0277': 631,
-'uni0274': 628,
-'uni0275': 629,
-'uni2252': 8786,
-'uni041F': 1055,
-'uni2250': 8784,
-'Z': 90,
-'uni2256': 8790,
-'uni2257': 8791,
-'copyright': 169,
-'uni2255': 8789,
-'uni043D': 1085,
-'uni043E': 1086,
-'uni043F': 1087,
-'yen': 165,
-'uni041D': 1053,
-'uni043B': 1083,
-'uni043C': 1084,
-'uni21B0': 8624,
-'uni21B1': 8625,
-'uni21B2': 8626,
-'uni21B3': 8627,
-'uni21B4': 8628,
-'uni21B5': 8629,
-'uni21B6': 8630,
-'uni21B7': 8631,
-'uni21B8': 8632,
-'Eacute': 201,
-'uni2311': 8977,
-'uni2310': 8976,
-'uni228F': 8847,
-'uni25DB': 9691,
-'uni21BA': 8634,
-'uni21BB': 8635,
-'uni21BC': 8636,
-'uni2017': 8215,
-'uni21BE': 8638,
-'uni21BF': 8639,
-'uni231C': 8988,
-'H': 72,
-'uni0293': 659,
-'uni2202': 8706,
-'uni22A4': 8868,
-'uni231E': 8990,
-'uni2232': 8754,
-'uni225B': 8795,
-'uni225C': 8796,
-'uni24D9': 9433,
-'uni225A': 8794,
-'uni0438': 1080,
-'uni0439': 1081,
-'uni225D': 8797,
-'uni225E': 8798,
-'uni0434': 1076,
-'X': 88,
-'uni007F': 127,
-'uni0437': 1079,
-'Idieresis': 207,
-'uni0431': 1073,
-'uni0432': 1074,
-'uni0433': 1075,
-'uni22AC': 8876,
-'uni22CD': 8909,
-'uni25A3': 9635,
-'bar': 124,
-'uni24BB': 9403,
-'uni037E': 894,
-'uni027B': 635,
-'h': 104,
-'uni027A': 634,
-'uni027F': 639,
-'uni027D': 637,
-'uni027E': 638,
-'uni2227': 8743,
-'uni2004': 8196,
-'uni2225': 8741,
-'uni2224': 8740,
-'uni2223': 8739,
-'uni2222': 8738,
-'uni2221': 8737,
-'uni2220': 8736,
-'x': 120,
-'uni2323': 8995,
-'uni2559': 9561,
-'uni2558': 9560,
-'uni2229': 8745,
-'uni2228': 8744,
-'udieresis': 252,
-'uni029D': 669,
-'ordfeminine': 170,
-'uni22CB': 8907,
-'uni233D': 9021,
-'uni0428': 1064,
-'uni24C6': 9414,
-'uni22DD': 8925,
-'uni24C7': 9415,
-'uni015C': 348,
-'uni015B': 347,
-'uni015A': 346,
-'uni22AA': 8874,
-'uni015F': 351,
-'uni015E': 350,
-'braceleft': 123,
-'uni24C5': 9413,
-'uni0410': 1040,
-'uni03AA': 938,
-'uni24C2': 9410,
-'uni03AC': 940,
-'uni03AB': 939,
-'macron': 175,
-'uni03AD': 941,
-'uni03AF': 943,
-'uni0294': 660,
-'uni0295': 661,
-'uni0296': 662,
-'uni0297': 663,
-'uni0290': 656,
-'uni0291': 657,
-'uni0292': 658,
-'atilde': 227,
-'Acircumflex': 194,
-'uni2370': 9072,
-'uni24C1': 9409,
-'uni0298': 664,
-'uni0299': 665,
-'Oslash': 216,
-'uni029E': 670,
-'C': 67,
-'quotedblleft': 8220,
-'uni029B': 667,
-'uni029C': 668,
-'uni03A9': 937,
-'uni03A8': 936,
-'S': 83,
-'uni24C9': 9417,
-'uni03A1': 929,
-'uni03A0': 928,
-'exclam': 33,
-'uni03A5': 933,
-'uni03A4': 932,
-'uni03A7': 935,
-'Zcaron': 381,
-'uni2133': 8499,
-'uni2132': 8498,
-'uni0159': 345,
-'uni0158': 344,
-'uni2137': 8503,
-'uni2005': 8197,
-'uni2135': 8501,
-'uni2134': 8500,
-'uni02BA': 698,
-'uni2033': 8243,
-'uni0151': 337,
-'uni0150': 336,
-'uni0157': 343,
-'equal': 61,
-'uni0155': 341,
-'uni0154': 340,
-'s': 115,
-'uni233F': 9023,
-'eth': 240,
-'uni24BE': 9406,
-'uni21E9': 8681,
-'uni2060': 8288,
-'Egrave': 200,
-'uni255D': 9565,
-'uni24CD': 9421,
-'uni21E1': 8673,
-'uni21B9': 8633,
-'hyphen': 45,
-'uni01BE': 446,
-'uni01BB': 443,
-'period': 46,
-'igrave': 236,
-'uni01BA': 442,
-'uni2296': 8854,
-'uni2297': 8855,
-'uni2294': 8852,
-'uni2295': 8853,
-'colon': 58,
-'uni2293': 8851,
-'uni2290': 8848,
-'uni2291': 8849,
-'uni032D': 813,
-'uni032E': 814,
-'uni032F': 815,
-'uni032A': 810,
-'uni032B': 811,
-'uni032C': 812,
-'uni231D': 8989,
-'Ecircumflex': 202,
-'uni24D7': 9431,
-'uni25DD': 9693,
-'trademark': 8482,
-'Aacute': 193,
-'cent': 162,
-'uni0445': 1093,
-'uni266E': 9838,
-'uni266D': 9837,
-'uni266B': 9835,
-'uni03C9': 969,
-'uni2003': 8195,
-'uni2047': 8263,
-'lslash': 322,
-'uni03A6': 934,
-'uni2043': 8259,
-'uni250C': 9484,
-'uni2040': 8256,
-'uni255F': 9567,
-'uni24CB': 9419,
-'uni0472': 1138,
-'uni0446': 1094,
-'uni0474': 1140,
-'uni0475': 1141,
-'uni2508': 9480,
-'uni2660': 9824,
-'uni2506': 9478,
-'uni2502': 9474,
-'c': 99,
-'uni2500': 9472,
-'N': 78,
-'uni22A6': 8870,
-'uni21E7': 8679,
-'uni2130': 8496,
-'uni2002': 8194,
-'breve': 728,
-'uni0442': 1090,
-'Oacute': 211,
-'uni229F': 8863,
-'uni25C7': 9671,
-'uni229D': 8861,
-'uni229E': 8862,
-'guillemotleft': 171,
-'uni0329': 809,
-'uni24E5': 9445,
-'uni011F': 287,
-'uni0324': 804,
-'uni0325': 805,
-'uni0326': 806,
-'uni0327': 807,
-'uni0321': 801,
-'uni0322': 802,
-'n': 110,
-'uni2032': 8242,
-'uni2269': 8809,
-'uni2268': 8808,
-'uni0306': 774,
-'uni226B': 8811,
-'uni21EA': 8682,
-'uni0166': 358,
-'uni203B': 8251,
-'uni01B5': 437,
-'idieresis': 239,
-'uni02BC': 700,
-'uni01B0': 432,
-'braceright': 125,
-'seven': 55,
-'uni02BB': 699,
-'uni011A': 282,
-'uni29FB': 10747,
-'brokenbar': 166,
-'uni2036': 8246,
-'uni25C0': 9664,
-'uni0156': 342,
-'uni22D5': 8917,
-'uni0258': 600,
-'ugrave': 249,
-'uni22D6': 8918,
-'uni22D1': 8913,
-'uni2034': 8244,
-'uni22D3': 8915,
-'uni22D2': 8914,
-'uni203C': 8252,
-'uni223E': 8766,
-'uni02BF': 703,
-'uni22D9': 8921,
-'uni22D8': 8920,
-'uni25BD': 9661,
-'uni25BE': 9662,
-'uni25BF': 9663,
-'uni041B': 1051,
-'periodcentered': 183,
-'uni25BC': 9660,
-'uni019E': 414,
-'uni019B': 411,
-'uni019A': 410,
-'uni2007': 8199,
-'uni0391': 913,
-'uni0390': 912,
-'uni0393': 915,
-'uni0392': 914,
-'uni0395': 917,
-'uni0394': 916,
-'uni0397': 919,
-'uni0396': 918,
-'uni0399': 921,
-'uni0398': 920,
-'uni25C8': 9672,
-'uni2468': 9320,
-'sterling': 163,
-'uni22EB': 8939,
-'uni039C': 924,
-'uni039B': 923,
-'uni039E': 926,
-'uni039D': 925,
-'uni039F': 927,
-'I': 73,
-'uni03E1': 993,
-'uni03E0': 992,
-'uni2319': 8985,
-'uni228B': 8843,
-'uni25B5': 9653,
-'uni25B6': 9654,
-'uni22EA': 8938,
-'uni24B9': 9401,
-'uni044E': 1102,
-'uni0199': 409,
-'uni2266': 8806,
-'Y': 89,
-'uni22A2': 8866,
-'Eth': 208,
-'uni266F': 9839,
-'emdash': 8212,
-'uni263B': 9787,
-'uni24BD': 9405,
-'uni22DE': 8926,
-'uni0360': 864,
-'uni2557': 9559,
-'uni22DF': 8927,
-'uni22DA': 8922,
-'uni22DC': 8924,
-'uni0361': 865,
-'i': 105,
-'uni24BF': 9407,
-'uni0362': 866,
-'uni263E': 9790,
-'uni028D': 653,
-'uni2259': 8793,
-'uni0323': 803,
-'uni2265': 8805,
-'daggerdbl': 8225,
-'y': 121,
-'uni010A': 266,
-'plusminus': 177,
-'less': 60,
-'uni21AE': 8622,
-'uni0315': 789,
-'uni230B': 8971,
-'uni21AF': 8623,
-'uni21AA': 8618,
-'uni21AC': 8620,
-'uni21AB': 8619,
-'uni01FB': 507,
-'uni01FC': 508,
-'uni223A': 8762,
-'uni01FA': 506,
-'uni01FF': 511,
-'uni01FD': 509,
-'uni01FE': 510,
-'uni2567': 9575,
-'uni25E0': 9696,
-'uni0104': 260,
-'uni0105': 261,
-'uni0106': 262,
-'uni0107': 263,
-'uni0100': 256,
-'uni0101': 257,
-'uni0102': 258,
-'uni0103': 259,
-'uni2038': 8248,
-'uni2009': 8201,
-'uni2008': 8200,
-'uni0108': 264,
-'uni0109': 265,
-'uni02A1': 673,
-'uni...
[truncated message content] |
|
From: <evi...@us...> - 2009-07-22 13:49:44
|
Revision: 7284
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7284&view=rev
Author: evilguru
Date: 2009-07-22 13:49:38 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Remove mathtext.py from matplotlib and fix a bug in the OS X backend.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_macosx.py
Removed Paths:
-------------
branches/mathtex/lib/matplotlib/mathtext.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22 13:47:42 UTC (rev 7283)
+++ branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22 13:49:38 UTC (rev 7284)
@@ -43,7 +43,6 @@
self.width = width
self.height = height
self.gc = GraphicsContextMac()
- self.mathtext_parser = MathTextParser('MacOSX')
def set_width_height (self, width, height):
self.width, self.height = width, height
Deleted: branches/mathtex/lib/matplotlib/mathtext.py
===================================================================
--- branches/mathtex/lib/matplotlib/mathtext.py 2009-07-22 13:47:42 UTC (rev 7283)
+++ branches/mathtex/lib/matplotlib/mathtext.py 2009-07-22 13:49:38 UTC (rev 7284)
@@ -1,2930 +0,0 @@
-r"""
-:mod:`~matplotlib.mathtext` is a module for parsing a subset of the
-TeX math syntax and drawing them to a matplotlib backend.
-
-For a tutorial of its usage see :ref:`mathtext-tutorial`. This
-document is primarily concerned with implementation details.
-
-The module uses pyparsing_ to parse the TeX expression.
-
-.. _pyparsing: http://pyparsing.wikispaces.com/
-
-The Bakoma distribution of the TeX Computer Modern fonts, and STIX
-fonts are supported. There is experimental support for using
-arbitrary fonts, but results may vary without proper tweaking and
-metrics for those fonts.
-
-If you find TeX expressions that don't parse or render properly,
-please email md...@st..., but please check KNOWN ISSUES below first.
-"""
-from __future__ import division
-import os
-from cStringIO import StringIO
-from math import ceil
-try:
- set
-except NameError:
- from sets import Set as set
-import unicodedata
-from warnings import warn
-
-from numpy import inf, isinf
-import numpy as np
-from matplotlib.pyparsing import Combine, Group, Optional, Forward, \
- Literal, OneOrMore, ZeroOrMore, ParseException, Empty, \
- ParseResults, Suppress, oneOf, StringEnd, ParseFatalException, \
- FollowedBy, Regex, ParserElement
-# Enable packrat parsing
-ParserElement.enablePackrat()
-
-from matplotlib.afm import AFM
-from matplotlib.cbook import Bunch, get_realpath_and_stat, \
- is_string_like, maxdict
-from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING
-from matplotlib.font_manager import findfont, FontProperties
-from matplotlib._mathtext_data import latex_to_bakoma, \
- latex_to_standard, tex2uni, latex_to_cmex, stix_virtual_fonts
-from matplotlib import get_data_path, rcParams
-
-
-
-import matplotlib.colors as mcolors
-import matplotlib._png as _png
-####################
-
-
-
-##############################################################################
-# FONTS
-
-def get_unicode_index(symbol):
- """get_unicode_index(symbol) -> integer
-
-Return the integer index (from the Unicode table) of symbol. *symbol*
-can be a single unicode character, a TeX command (i.e. r'\pi'), or a
-Type1 symbol name (i.e. 'phi').
-"""
- # From UTF #25: U+2212 minus sign is the preferred
- # representation of the unary and binary minus sign rather than
- # the ASCII-derived U+002D hyphen-minus, because minus sign is
- # unambiguous and because it is rendered with a more desirable
- # length, usually longer than a hyphen.
- if symbol == '-':
- return 0x2212
- try:# This will succeed if symbol is a single unicode char
- return ord(symbol)
- except TypeError:
- pass
- try:# Is symbol a TeX symbol (i.e. \alpha)
- return tex2uni[symbol.strip("\\")]
- except KeyError:
- message = """'%(symbol)s' is not a valid Unicode character or
-TeX/Type1 symbol"""%locals()
- raise ValueError, message
-
-
-class MathtextBackend(object):
- """
- The base class for the mathtext backend-specific code. The
- purpose of :class:`MathtextBackend` subclasses is to interface
- between mathtext and a specific matplotlib graphics backend.
-
- Subclasses need to override the following:
-
- - :meth:`render_glyph`
- - :meth:`render_filled_rect`
- - :meth:`get_results`
-
- And optionally, if you need to use a Freetype hinting style:
-
- - :meth:`get_hinting_type`
- """
- def __init__(self):
- self.fonts_object = None
-
- def set_canvas_size(self, w, h, d):
- 'Dimension the drawing canvas'
- self.width = w
- self.height = h
- self.depth = d
-
- def render_glyph(self, ox, oy, info):
- """
- Draw a glyph described by *info* to the reference point (*ox*,
- *oy*).
- """
- raise NotImplementedError()
-
- def render_filled_rect(self, x1, y1, x2, y2):
- """
- Draw a filled black rectangle from (*x1*, *y1*) to (*x2*, *y2*).
- """
- raise NotImplementedError()
-
- def get_results(self, box):
- """
- Return a backend-specific tuple to return to the backend after
- all processing is done.
- """
- raise NotImplementedError()
-
- def get_hinting_type(self):
- """
- Get the Freetype hinting type to use with this particular
- backend.
- """
- return LOAD_NO_HINTING
-
-class MathtextBackendBbox(MathtextBackend):
- """
- A backend whose only purpose is to get a precise bounding box.
- Only required for the Agg backend.
- """
-
- def __init__(self, real_backend):
- MathtextBackend.__init__(self)
- self.bbox = [0, 0, 0, 0]
- self.real_backend = real_backend
-
- def _update_bbox(self, x1, y1, x2, y2):
- self.bbox = [min(self.bbox[0], x1),
- min(self.bbox[1], y1),
- max(self.bbox[2], x2),
- max(self.bbox[3], y2)]
-
- def render_glyph(self, ox, oy, info):
- self._update_bbox(ox + info.metrics.xmin,
- oy - info.metrics.ymax,
- ox + info.metrics.xmax,
- oy - info.metrics.ymin)
-
- def render_rect_filled(self, x1, y1, x2, y2):
- self._update_bbox(x1, y1, x2, y2)
-
- def get_results(self, box):
- orig_height = box.height
- orig_depth = box.depth
- ship(0, 0, box)
- bbox = self.bbox
- bbox = [bbox[0] - 1, bbox[1] - 1, bbox[2] + 1, bbox[3] + 1]
- self._switch_to_real_backend()
- self.fonts_object.set_canvas_size(
- bbox[2] - bbox[0],
- (bbox[3] - bbox[1]) - orig_depth,
- (bbox[3] - bbox[1]) - orig_height)
- ship(-bbox[0], -bbox[1], box)
- return self.fonts_object.get_results(box)
-
- def get_hinting_type(self):
- return self.real_backend.get_hinting_type()
-
- def _switch_to_real_backend(self):
- self.fonts_object.mathtext_backend = self.real_backend
- self.real_backend.fonts_object = self.fonts_object
- self.real_backend.ox = self.bbox[0]
- self.real_backend.oy = self.bbox[1]
-
-class MathtextBackendAggRender(MathtextBackend):
- """
- Render glyphs and rectangles to an FTImage buffer, which is later
- transferred to the Agg image by the Agg backend.
- """
- def __init__(self):
- self.ox = 0
- self.oy = 0
- self.image = None
- MathtextBackend.__init__(self)
-
- def set_canvas_size(self, w, h, d):
- MathtextBackend.set_canvas_size(self, w, h, d)
- self.image = FT2Image(ceil(w), ceil(h + d))
-
- def render_glyph(self, ox, oy, info):
- info.font.draw_glyph_to_bitmap(
- self.image, ox, oy - info.metrics.iceberg, info.glyph)
-
- def render_rect_filled(self, x1, y1, x2, y2):
- height = max(int(y2 - y1) - 1, 0)
- if height == 0:
- center = (y2 + y1) / 2.0
- y = int(center - (height + 1) / 2.0)
- else:
- y = int(y1)
- self.image.draw_rect_filled(int(x1), y, ceil(x2), y + height)
-
- def get_results(self, box):
- return (self.ox,
- self.oy,
- self.width,
- self.height + self.depth,
- self.depth,
- self.image,
- self.fonts_object.get_used_characters())
-
- def get_hinting_type(self):
- return LOAD_FORCE_AUTOHINT
-
-def MathtextBackendAgg():
- return MathtextBackendBbox(MathtextBackendAggRender())
-
-class MathtextBackendBitmapRender(MathtextBackendAggRender):
- def get_results(self, box):
- return self.image, self.depth
-
-def MathtextBackendBitmap():
- """
- A backend to generate standalone mathtext images. No additional
- matplotlib backend is required.
- """
- return MathtextBackendBbox(MathtextBackendBitmapRender())
-
-class MathtextBackendPs(MathtextBackend):
- """
- Store information to write a mathtext rendering to the PostScript
- backend.
- """
- def __init__(self):
- self.pswriter = StringIO()
- self.lastfont = None
-
- def render_glyph(self, ox, oy, info):
- oy = self.height - oy + info.offset
- postscript_name = info.postscript_name
- fontsize = info.fontsize
- symbol_name = info.symbol_name
-
- if (postscript_name, fontsize) != self.lastfont:
- ps = """/%(postscript_name)s findfont
-%(fontsize)s scalefont
-setfont
-""" % locals()
- self.lastfont = postscript_name, fontsize
- self.pswriter.write(ps)
-
- ps = """%(ox)f %(oy)f moveto
-/%(symbol_name)s glyphshow\n
-""" % locals()
- self.pswriter.write(ps)
-
- def render_rect_filled(self, x1, y1, x2, y2):
- ps = "%f %f %f %f rectfill\n" % (x1, self.height - y2, x2 - x1, y2 - y1)
- self.pswriter.write(ps)
-
- def get_results(self, box):
- ship(0, -self.depth, box)
- #print self.depth
- return (self.width,
- self.height + self.depth,
- self.depth,
- self.pswriter,
- self.fonts_object.get_used_characters())
-
-class MathtextBackendPdf(MathtextBackend):
- """
- Store information to write a mathtext rendering to the PDF
- backend.
- """
- def __init__(self):
- self.glyphs = []
- self.rects = []
-
- def render_glyph(self, ox, oy, info):
- filename = info.font.fname
- oy = self.height - oy + info.offset
- self.glyphs.append(
- (ox, oy, filename, info.fontsize,
- info.num, info.symbol_name))
-
- def render_rect_filled(self, x1, y1, x2, y2):
- self.rects.append((x1, self.height - y2, x2 - x1, y2 - y1))
-
- def get_results(self, box):
- ship(0, -self.depth, box)
- return (self.width,
- self.height + self.depth,
- self.depth,
- self.glyphs,
- self.rects,
- self.fonts_object.get_used_characters())
-
-class MathtextBackendSvg(MathtextBackend):
- """
- Store information to write a mathtext rendering to the SVG
- backend.
- """
- def __init__(self):
- self.svg_glyphs = []
- self.svg_rects = []
-
- def render_glyph(self, ox, oy, info):
- oy = self.height - oy + info.offset
- thetext = unichr(info.num)
- self.svg_glyphs.append(
- (info.font, info.fontsize, thetext, ox, oy, info.metrics))
-
- def render_rect_filled(self, x1, y1, x2, y2):
- self.svg_rects.append(
- (x1, self.height - y1 + 1, x2 - x1, y2 - y1))
-
- def get_results(self, box):
- ship(0, -self.depth, box)
- svg_elements = Bunch(svg_glyphs = self.svg_glyphs,
- svg_rects = self.svg_rects)
- return (self.width,
- self.height + self.depth,
- self.depth,
- svg_elements,
- self.fonts_object.get_used_characters())
-
-class MathtextBackendCairo(MathtextBackend):
- """
- Store information to write a mathtext rendering to the Cairo
- backend.
- """
-
- def __init__(self):
- self.glyphs = []
- self.rects = []
-
- def render_glyph(self, ox, oy, info):
- oy = oy - info.offset - self.height
- thetext = unichr(info.num)
- self.glyphs.append(
- (info.font, info.fontsize, thetext, ox, oy))
-
- def render_rect_filled(self, x1, y1, x2, y2):
- self.rects.append(
- (x1, y1 - self.height, x2 - x1, y2 - y1))
-
- def get_results(self, box):
- ship(0, -self.depth, box)
- return (self.width,
- self.height + self.depth,
- self.depth,
- self.glyphs,
- self.rects)
-
-class Fonts(object):
- """
- An abstract base class for a system of fonts to use for mathtext.
-
- The class must be able to take symbol keys and font file names and
- return the character metrics. It also delegates to a backend class
- to do the actual drawing.
- """
-
- def __init__(self, default_font_prop, mathtext_backend):
- """
- *default_font_prop*: A
- :class:`~matplotlib.font_manager.FontProperties` object to use
- for the default non-math font, or the base font for Unicode
- (generic) font rendering.
-
- *mathtext_backend*: A subclass of :class:`MathTextBackend`
- used to delegate the actual rendering.
- """
- self.default_font_prop = default_font_prop
- self.mathtext_backend = mathtext_backend
- # Make these classes doubly-linked
- self.mathtext_backend.fonts_object = self
- self.used_characters = {}
-
- def destroy(self):
- """
- Fix any cyclical references before the object is about
- to be destroyed.
- """
- self.used_characters = None
-
- def get_kern(self, font1, fontclass1, sym1, fontsize1,
- font2, fontclass2, sym2, fontsize2, dpi):
- """
- Get the kerning distance for font between *sym1* and *sym2*.
-
- *fontX*: one of the TeX font names::
-
- tt, it, rm, cal, sf, bf or default/regular (non-math)
-
- *fontclassX*: TODO
-
- *symX*: a symbol in raw TeX form. e.g. '1', 'x' or '\sigma'
-
- *fontsizeX*: the fontsize in points
-
- *dpi*: the current dots-per-inch
- """
- return 0.
-
- def get_metrics(self, font, font_class, sym, fontsize, dpi):
- """
- *font*: one of the TeX font names::
-
- tt, it, rm, cal, sf, bf or default/regular (non-math)
-
- *font_class*: TODO
-
- *sym*: a symbol in raw TeX form. e.g. '1', 'x' or '\sigma'
-
- *fontsize*: font size in points
-
- *dpi*: current dots-per-inch
-
- Returns an object with the following attributes:
-
- - *advance*: The advance distance (in points) of the glyph.
-
- - *height*: The height of the glyph in points.
-
- - *width*: The width of the glyph in points.
-
- - *xmin*, *xmax*, *ymin*, *ymax* - the ink rectangle of the glyph
-
- - *iceberg* - the distance from the baseline to the top of
- the glyph. This corresponds to TeX's definition of
- "height".
- """
- info = self._get_info(font, font_class, sym, fontsize, dpi)
- return info.metrics
-
- def set_canvas_size(self, w, h, d):
- """
- Set the size of the buffer used to render the math expression.
- Only really necessary for the bitmap backends.
- """
- self.width, self.height, self.depth = ceil(w), ceil(h), ceil(d)
- self.mathtext_backend.set_canvas_size(self.width, self.height, self.depth)
-
- def render_glyph(self, ox, oy, facename, font_class, sym, fontsize, dpi):
- """
- Draw a glyph at
-
- - *ox*, *oy*: position
-
- - *facename*: One of the TeX face names
-
- - *font_class*:
-
- - *sym*: TeX symbol name or single character
-
- - *fontsize*: fontsize in points
-
- - *dpi*: The dpi to draw at.
- """
- info = self._get_info(facename, font_class, sym, fontsize, dpi)
- realpath, stat_key = get_realpath_and_stat(info.font.fname)
- used_characters = self.used_characters.setdefault(
- stat_key, (realpath, set()))
- used_characters[1].add(info.num)
- self.mathtext_backend.render_glyph(ox, oy, info)
-
- def render_rect_filled(self, x1, y1, x2, y2):
- """
- Draw a filled rectangle from (*x1*, *y1*) to (*x2*, *y2*).
- """
- self.mathtext_backend.render_rect_filled(x1, y1, x2, y2)
-
- def get_xheight(self, font, fontsize, dpi):
- """
- Get the xheight for the given *font* and *fontsize*.
- """
- raise NotImplementedError()
-
- def get_underline_thickness(self, font, fontsize, dpi):
- """
- Get the line thickness that matches the given font. Used as a
- base unit for drawing lines such as in a fraction or radical.
- """
- raise NotImplementedError()
-
- def get_used_characters(self):
- """
- Get the set of characters that were used in the math
- expression. Used by backends that need to subset fonts so
- they know which glyphs to include.
- """
- return self.used_characters
-
- def get_results(self, box):
- """
- Get the data needed by the backend to render the math
- expression. The return value is backend-specific.
- """
- return self.mathtext_backend.get_results(box)
-
- def get_sized_alternatives_for_symbol(self, fontname, sym):
- """
- Override if your font provides multiple sizes of the same
- symbol. Should return a list of symbols matching *sym* in
- various sizes. The expression renderer will select the most
- appropriate size for a given situation from this list.
- """
- return [(fontname, sym)]
-
-class TruetypeFonts(Fonts):
- """
- A generic base class for all font setups that use Truetype fonts
- (through FT2Font).
- """
- class CachedFont:
- def __init__(self, font):
- self.font = font
- self.charmap = font.get_charmap()
- self.glyphmap = dict(
- [(glyphind, ccode) for ccode, glyphind in self.charmap.iteritems()])
-
- def __repr__(self):
- return repr(self.font)
-
- def __init__(self, default_font_prop, mathtext_backend):
- Fonts.__init__(self, default_font_prop, mathtext_backend)
- self.glyphd = {}
- self._fonts = {}
-
- filename = findfont(default_font_prop)
- default_font = self.CachedFont(FT2Font(str(filename)))
- self._fonts['default'] = default_font
- self._fonts['regular'] = default_font
-
- def destroy(self):
- self.glyphd = None
- Fonts.destroy(self)
-
- def _get_font(self, font):
- if font in self.fontmap:
- basename = self.fontmap[font]
- else:
- basename = font
-
- cached_font = self._fonts.get(basename)
- if cached_font is None:
- font = FT2Font(basename)
- cached_font = self.CachedFont(font)
- self._fonts[basename] = cached_font
- self._fonts[font.postscript_name] = cached_font
- self._fonts[font.postscript_name.lower()] = cached_font
- return cached_font
-
- def _get_offset(self, cached_font, glyph, fontsize, dpi):
- if cached_font.font.postscript_name == 'Cmex10':
- return glyph.height/64.0/2.0 + 256.0/64.0 * dpi/72.0
- return 0.
-
- def _get_info(self, fontname, font_class, sym, fontsize, dpi):
- key = fontname, font_class, sym, fontsize, dpi
- bunch = self.glyphd.get(key)
- if bunch is not None:
- return bunch
-
- cached_font, num, symbol_name, fontsize, slanted = \
- self._get_glyph(fontname, font_class, sym, fontsize)
-
- font = cached_font.font
- font.set_size(fontsize, dpi)
- glyph = font.load_char(
- num,
- flags=self.mathtext_backend.get_hinting_type())
-
- xmin, ymin, xmax, ymax = [val/64.0 for val in glyph.bbox]
- offset = self._get_offset(cached_font, glyph, fontsize, dpi)
- metrics = Bunch(
- advance = glyph.linearHoriAdvance/65536.0,
- height = glyph.height/64.0,
- width = glyph.width/64.0,
- xmin = xmin,
- xmax = xmax,
- ymin = ymin+offset,
- ymax = ymax+offset,
- # iceberg is the equivalent of TeX's "height"
- iceberg = glyph.horiBearingY/64.0 + offset,
- slanted = slanted
- )
-
- result = self.glyphd[key] = Bunch(
- font = font,
- fontsize = fontsize,
- postscript_name = font.postscript_name,
- metrics = metrics,
- symbol_name = symbol_name,
- num = num,
- glyph = glyph,
- offset = offset
- )
- return result
-
- def get_xheight(self, font, fontsize, dpi):
- cached_font = self._get_font(font)
- cached_font.font.set_size(fontsize, dpi)
- pclt = cached_font.font.get_sfnt_table('pclt')
- if pclt is None:
- # Some fonts don't store the xHeight, so we do a poor man's xHeight
- metrics = self.get_metrics(font, rcParams['mathtext.default'], 'x', fontsize, dpi)
- return metrics.iceberg
- xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
- return xHeight
-
- def get_underline_thickness(self, font, fontsize, dpi):
- # This function used to grab underline thickness from the font
- # metrics, but that information is just too un-reliable, so it
- # is now hardcoded.
- return ((0.75 / 12.0) * fontsize * dpi) / 72.0
-
- def get_kern(self, font1, fontclass1, sym1, fontsize1,
- font2, fontclass2, sym2, fontsize2, dpi):
- if font1 == font2 and fontsize1 == fontsize2:
- info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
- info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
- font = info1.font
- return font.get_kerning(info1.num, info2.num, KERNING_DEFAULT) / 64.0
- return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1,
- font2, fontclass2, sym2, fontsize2, dpi)
-
-class BakomaFonts(TruetypeFonts):
- """
- Use the Bakoma TrueType fonts for rendering.
-
- Symbols are strewn about a number of font files, each of which has
- its own proprietary 8-bit encoding.
- """
- _fontmap = { 'cal' : 'cmsy10',
- 'rm' : 'cmr10',
- 'tt' : 'cmtt10',
- 'it' : 'cmmi10',
- 'bf' : 'cmb10',
- 'sf' : 'cmss10',
- 'ex' : 'cmex10'
- }
-
- def __init__(self, *args, **kwargs):
- self._stix_fallback = StixFonts(*args, **kwargs)
-
- TruetypeFonts.__init__(self, *args, **kwargs)
- self.fontmap = {}
- for key, val in self._fontmap.iteritems():
- fullpath = findfont(val)
- self.fontmap[key] = fullpath
- self.fontmap[val] = fullpath
-
-
- _slanted_symbols = set(r"\int \oint".split())
-
- def _get_glyph(self, fontname, font_class, sym, fontsize):
- symbol_name = None
- if fontname in self.fontmap and sym in latex_to_bakoma:
- basename, num = latex_to_bakoma[sym]
- slanted = (basename == "cmmi10") or sym in self._slanted_symbols
- try:
- cached_font = self._get_font(basename)
- except RuntimeError:
- pass
- else:
- symbol_name = cached_font.font.get_glyph_name(num)
- num = cached_font.glyphmap[num]
- elif len(sym) == 1:
- slanted = (fontname == "it")
- try:
- cached_font = self._get_font(fontname)
- except RuntimeError:
- pass
- else:
- num = ord(sym)
- gid = cached_font.charmap.get(num)
- if gid is not None:
- symbol_name = cached_font.font.get_glyph_name(
- cached_font.charmap[num])
-
- if symbol_name is None:
- return self._stix_fallback._get_glyph(
- fontname, font_class, sym, fontsize)
-
- return cached_font, num, symbol_name, fontsize, slanted
-
- # The Bakoma fonts contain many pre-sized alternatives for the
- # delimiters. The AutoSizedChar class will use these alternatives
- # and select the best (closest sized) glyph.
- _size_alternatives = {
- '(' : [('rm', '('), ('ex', '\xa1'), ('ex', '\xb3'),
- ('ex', '\xb5'), ('ex', '\xc3')],
- ')' : [('rm', ')'), ('ex', '\xa2'), ('ex', '\xb4'),
- ('ex', '\xb6'), ('ex', '\x21')],
- '{' : [('cal', '{'), ('ex', '\xa9'), ('ex', '\x6e'),
- ('ex', '\xbd'), ('ex', '\x28')],
- '}' : [('cal', '}'), ('ex', '\xaa'), ('ex', '\x6f'),
- ('ex', '\xbe'), ('ex', '\x29')],
- # The fourth size of '[' is mysteriously missing from the BaKoMa
- # font, so I've ommitted it for both '[' and ']'
- '[' : [('rm', '['), ('ex', '\xa3'), ('ex', '\x68'),
- ('ex', '\x22')],
- ']' : [('rm', ']'), ('ex', '\xa4'), ('ex', '\x69'),
- ('ex', '\x23')],
- r'\lfloor' : [('ex', '\xa5'), ('ex', '\x6a'),
- ('ex', '\xb9'), ('ex', '\x24')],
- r'\rfloor' : [('ex', '\xa6'), ('ex', '\x6b'),
- ('ex', '\xba'), ('ex', '\x25')],
- r'\lceil' : [('ex', '\xa7'), ('ex', '\x6c'),
- ('ex', '\xbb'), ('ex', '\x26')],
- r'\rceil' : [('ex', '\xa8'), ('ex', '\x6d'),
- ('ex', '\xbc'), ('ex', '\x27')],
- r'\langle' : [('ex', '\xad'), ('ex', '\x44'),
- ('ex', '\xbf'), ('ex', '\x2a')],
- r'\rangle' : [('ex', '\xae'), ('ex', '\x45'),
- ('ex', '\xc0'), ('ex', '\x2b')],
- r'\__sqrt__' : [('ex', '\x70'), ('ex', '\x71'),
- ('ex', '\x72'), ('ex', '\x73')],
- r'\backslash': [('ex', '\xb2'), ('ex', '\x2f'),
- ('ex', '\xc2'), ('ex', '\x2d')],
- r'/' : [('rm', '/'), ('ex', '\xb1'), ('ex', '\x2e'),
- ('ex', '\xcb'), ('ex', '\x2c')],
- r'\widehat' : [('rm', '\x5e'), ('ex', '\x62'), ('ex', '\x63'),
- ('ex', '\x64')],
- r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'),
- ('ex', '\x67')],
- r'<' : [('cal', 'h'), ('ex', 'D')],
- r'>' : [('cal', 'i'), ('ex', 'E')]
- }
-
- for alias, target in [('\leftparen', '('),
- ('\rightparent', ')'),
- ('\leftbrace', '{'),
- ('\rightbrace', '}'),
- ('\leftbracket', '['),
- ('\rightbracket', ']')]:
- _size_alternatives[alias] = _size_alternatives[target]
-
- def get_sized_alternatives_for_symbol(self, fontname, sym):
- return self._size_alternatives.get(sym, [(fontname, sym)])
-
-class UnicodeFonts(TruetypeFonts):
- """
- An abstract base class for handling Unicode fonts.
-
- While some reasonably complete Unicode fonts (such as DejaVu) may
- work in some situations, the only Unicode font I'm aware of with a
- complete set of math symbols is STIX.
-
- This class will "fallback" on the Bakoma fonts when a required
- symbol can not be found in the font.
- """
- use_cmex = True
-
- def __init__(self, *args, **kwargs):
- # This must come first so the backend's owner is set correctly
- if rcParams['mathtext.fallback_to_cm']:
- self.cm_fallback = BakomaFonts(*args, **kwargs)
- else:
- self.cm_fallback = None
- TruetypeFonts.__init__(self, *args, **kwargs)
- self.fontmap = {}
- for texfont in "cal rm tt it bf sf".split():
- prop = rcParams['mathtext.' + texfont]
- font = findfont(prop)
- self.fontmap[texfont] = font
- prop = FontProperties('cmex10')
- font = findfont(prop)
- self.fontmap['ex'] = font
-
- _slanted_symbols = set(r"\int \oint".split())
-
- def _map_virtual_font(self, fontname, font_class, uniindex):
- return fontname, uniindex
-
- def _get_glyph(self, fontname, font_class, sym, fontsize):
- found_symbol = False
-
- if self.use_cmex:
- uniindex = latex_to_cmex.get(sym)
- if uniindex is not None:
- fontname = 'ex'
- found_symbol = True
-
- if not found_symbol:
- try:
- uniindex = get_unicode_index(sym)
- found_symbol = True
- except ValueError:
- uniindex = ord('?')
- warn("No TeX to unicode mapping for '%s'" %
- sym.encode('ascii', 'backslashreplace'),
- MathTextWarning)
-
- fontname, uniindex = self._map_virtual_font(
- fontname, font_class, uniindex)
-
- # Only characters in the "Letter" class should be italicized in 'it'
- # mode. Greek capital letters should be Roman.
- if found_symbol:
- new_fontname = fontname
-
- if fontname == 'it':
- if uniindex < 0x10000:
- unistring = unichr(uniindex)
- if (not unicodedata.category(unistring)[0] == "L"
- or unicodedata.name(unistring).startswith("GREEK CAPITAL")):
- new_fontname = 'rm'
-
- slanted = (new_fontname == 'it') or sym in self._slanted_symbols
- found_symbol = False
- try:
- cached_font = self._get_font(new_fontname)
- except RuntimeError:
- pass
- else:
- try:
- glyphindex = cached_font.charmap[uniindex]
- found_symbol = True
- except KeyError:
- pass
-
- if not found_symbol:
- if self.cm_fallback:
- warn("Substituting with a symbol from Computer Modern.",
- MathTextWarning)
- return self.cm_fallback._get_glyph(
- fontname, 'it', sym, fontsize)
- else:
- if fontname in ('it', 'regular') and isinstance(self, StixFonts):
- return self._get_glyph('rm', font_class, sym, fontsize)
- warn("Font '%s' does not have a glyph for '%s'" %
- (fontname, sym.encode('ascii', 'backslashreplace')),
- MathTextWarning)
- warn("Substituting with a dummy symbol.", MathTextWarning)
- fontname = 'rm'
- new_fontname = fontname
- cached_font = self._get_font(fontname)
- uniindex = 0xA4 # currency character, for lack of anything better
- glyphindex = cached_font.charmap[uniindex]
- slanted = False
-
- symbol_name = cached_font.font.get_glyph_name(glyphindex)
- return cached_font, uniindex, symbol_name, fontsize, slanted
-
- def get_sized_alternatives_for_symbol(self, fontname, sym):
- if self.cm_fallback:
- return self.cm_fallback.get_sized_alternatives_for_symbol(
- fontname, sym)
- return [(fontname, sym)]
-
-class StixFonts(UnicodeFonts):
- """
- A font handling class for the STIX fonts.
-
- In addition to what UnicodeFonts provides, this class:
-
- - supports "virtual fonts" which are complete alpha numeric
- character sets with different font styles at special Unicode
- code points, such as "Blackboard".
-
- - handles sized alternative characters for the STIXSizeX fonts.
- """
- _fontmap = { 'rm' : 'STIXGeneral',
- 'it' : 'STIXGeneral:italic',
- 'bf' : 'STIXGeneral:weight=bold',
- 'nonunirm' : 'STIXNonUnicode',
- 'nonuniit' : 'STIXNonUnicode:italic',
- 'nonunibf' : 'STIXNonUnicode:weight=bold',
-
- 0 : 'STIXGeneral',
- 1 : 'STIXSize1',
- 2 : 'STIXSize2',
- 3 : 'STIXSize3',
- 4 : 'STIXSize4',
- 5 : 'STIXSize5'
- }
- use_cmex = False
- cm_fallback = False
- _sans = False
-
- def __init__(self, *args, **kwargs):
- TruetypeFonts.__init__(self, *args, **kwargs)
- self.fontmap = {}
- for key, name in self._fontmap.iteritems():
- fullpath = findfont(name)
- self.fontmap[key] = fullpath
- self.fontmap[name] = fullpath
-
- def _map_virtual_font(self, fontname, font_class, uniindex):
- # Handle these "fonts" that are actually embedded in
- # other fonts.
- mapping = stix_virtual_fonts.get(fontname)
- if (self._sans and mapping is None and
- fontname not in ('regular', 'default')):
- mapping = stix_virtual_fonts['sf']
- doing_sans_conversion = True
- else:
- doing_sans_conversion = False
-
- if mapping is not None:
- if isinstance(mapping, dict):
- mapping = mapping.get(font_class, 'rm')
-
- # Binary search for the source glyph
- lo = 0
- hi = len(mapping)
- while lo < hi:
- mid = (lo+hi)//2
- range = mapping[mid]
- if uniindex < range[0]:
- hi = mid
- elif uniindex <= range[1]:
- break
- else:
- lo = mid + 1
-
- if uniindex >= range[0] and uniindex <= range[1]:
- uniindex = uniindex - range[0] + range[3]
- fontname = range[2]
- elif not doing_sans_conversion:
- # This will generate a dummy character
- uniindex = 0x1
- fontname = rcParams['mathtext.default']
-
- # Handle private use area glyphs
- if (fontname in ('it', 'rm', 'bf') and
- uniindex >= 0xe000 and uniindex <= 0xf8ff):
- fontname = 'nonuni' + fontname
-
- return fontname, uniindex
-
- _size_alternatives = {}
- def get_sized_alternatives_for_symbol(self, fontname, sym):
- alternatives = self._size_alternatives.get(sym)
- if alternatives:
- return alternatives
-
- alternatives = []
- try:
- uniindex = get_unicode_index(sym)
- except ValueError:
- return [(fontname, sym)]
-
- fix_ups = {
- ord('<'): 0x27e8,
- ord('>'): 0x27e9 }
-
- uniindex = fix_ups.get(uniindex, uniindex)
-
- for i in range(6):
- cached_font = self._get_font(i)
- glyphindex = cached_font.charmap.get(uniindex)
- if glyphindex is not None:
- alternatives.append((i, unichr(uniindex)))
-
- self._size_alternatives[sym] = alternatives
- return alternatives
-
-class StixSansFonts(StixFonts):
- """
- A font handling class for the STIX fonts (that uses sans-serif
- characters by default).
- """
- _sans = True
-
-class StandardPsFonts(Fonts):
- """
- Use the standard postscript fonts for rendering to backend_ps
-
- Unlike the other font classes, BakomaFont and UnicodeFont, this
- one requires the Ps backend.
- """
- basepath = os.path.join( get_data_path(), 'fonts', 'afm' )
-
- fontmap = { 'cal' : 'pzcmi8a', # Zapf Chancery
- 'rm' : 'pncr8a', # New Century Schoolbook
- 'tt' : 'pcrr8a', # Courier
- 'it' : 'pncri8a', # New Century Schoolbook Italic
- 'sf' : 'phvr8a', # Helvetica
- 'bf' : 'pncb8a', # New Century Schoolbook Bold
- None : 'psyr' # Symbol
- }
-
- def __init__(self, default_font_prop):
- Fonts.__init__(self, default_font_prop, MathtextBackendPs())
- self.glyphd = {}
- self.fonts = {}
-
- filename = findfont(default_font_prop, fontext='afm')
- default_font = AFM(file(filename, 'r'))
- default_font.fname = filename
-
- self.fonts['default'] = default_font
- self.fonts['regular'] = default_font
- self.pswriter = StringIO()
-
- def _get_font(self, font):
- if font in self.fontmap:
- basename = self.fontmap[font]
- else:
- basename = font
-
- cached_font = self.fonts.get(basename)
- if cached_font is None:
- fname = os.path.join(self.basepath, basename + ".afm")
- cached_font = AFM(file(fname, 'r'))
- cached_font.fname = fname
- self.fonts[basename] = cached_font
- self.fonts[cached_font.get_fontname()] = cached_font
- return cached_font
-
- def _get_info (self, fontname, font_class, sym, fontsize, dpi):
- 'load the cmfont, metrics and glyph with caching'
- key = fontname, sym, fontsize, dpi
- tup = self.glyphd.get(key)
-
- if tup is not None:
- return tup
-
- # Only characters in the "Letter" class should really be italicized.
- # This class includes greek letters, so we're ok
- if (fontname == 'it' and
- (len(sym) > 1 or
- not unicodedata.category(unicode(sym)).startswith("L"))):
- fontname = 'rm'
-
- found_symbol = False
-
- if sym in latex_to_standard:
- fontname, num = latex_to_standard[sym]
- glyph = chr(num)
- found_symbol = True
- elif len(sym) == 1:
- glyph = sym
- num = ord(glyph)
- found_symbol = True
- else:
- warn("No TeX to built-in Postscript mapping for '%s'" % sym,
- MathTextWarning)
-
- slanted = (fontname == 'it')
- font = self._get_font(fontname)
-
- if found_symbol:
- try:
- symbol_name = font.get_name_char(glyph)
- except KeyError:
- warn("No glyph in standard Postscript font '%s' for '%s'" %
- (font.postscript_name, sym),
- MathTextWarning)
- found_symbol = False
-
- if not found_symbol:
- glyph = sym = '?'
- num = ord(glyph)
- symbol_name = font.get_name_char(glyph)
-
- offset = 0
-
- scale = 0.001 * fontsize
-
- xmin, ymin, xmax, ymax = [val * scale
- for val in font.get_bbox_char(glyph)]
- metrics = Bunch(
- advance = font.get_width_char(glyph) * scale,
- width = font.get_width_char(glyph) * scale,
- height = font.get_height_char(glyph) * scale,
- xmin = xmin,
- xmax = xmax,
- ymin = ymin+offset,
- ymax = ymax+offset,
- # iceberg is the equivalent of TeX's "height"
- iceberg = ymax + offset,
- slanted = slanted
- )
-
- self.glyphd[key] = Bunch(
- font = font,
- fontsize = fontsize,
- postscript_name = font.get_fontname(),
- metrics = metrics,
- symbol_name = symbol_name,
- num = num,
- glyph = glyph,
- offset = offset
- )
-
- return self.glyphd[key]
-
- def get_kern(self, font1, fontclass1, sym1, fontsize1,
- font2, fontclass2, sym2, fontsize2, dpi):
- if font1 == font2 and fontsize1 == fontsize2:
- info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
- info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
- font = info1.font
- return (font.get_kern_dist(info1.glyph, info2.glyph)
- * 0.001 * fontsize1)
- return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1,
- font2, fontclass2, sym2, fontsize2, dpi)
-
- def get_xheight(self, font, fontsize, dpi):
- cached_font = self._get_font(font)
- return cached_font.get_xheight() * 0.001 * fontsize
-
- def get_underline_thickness(self, font, fontsize, dpi):
- cached_font = self._get_font(font)
- return cached_font.get_underline_thickness() * 0.001 * fontsize
-
-##############################################################################
-# TeX-LIKE BOX MODEL
-
-# The following is based directly on the document 'woven' from the
-# TeX82 source code. This information is also available in printed
-# form:
-#
-# Knuth, Donald E.. 1986. Computers and Typesetting, Volume B:
-# TeX: The Program. Addison-Wesley Professional.
-#
-# The most relevant "chapters" are:
-# Data structures for boxes and their friends
-# Shipping pages out (Ship class)
-# Packaging (hpack and vpack)
-# Data structures for math mode
-# Subroutines for math mode
-# Typesetting math formulas
-#
-# Many of the docstrings below refer to a numbered "node" in that
-# book, e.g. node123
-#
-# Note that (as TeX) y increases downward, unlike many other parts of
-# matplotlib.
-
-# How much text shrinks when going to the next-smallest level. GROW_FACTOR
-# must be the inverse of SHRINK_FACTOR.
-SHRINK_FACTOR = 0.7
-GROW_FACTOR = 1.0 / SHRINK_FACTOR
-# The number of different sizes of chars to use, beyond which they will not
-# get any smaller
-NUM_SIZE_LEVELS = 4
-# Percentage of x-height of additional horiz. space after sub/superscripts
-SCRIPT_SPACE = 0.2
-# Percentage of x-height that sub/superscripts drop below the baseline
-SUBDROP = 0.3
-# Percentage of x-height that superscripts drop below the baseline
-SUP1 = 0.5
-# Percentage of x-height that subscripts drop below the baseline
-SUB1 = 0.0
-# Percentage of x-height that superscripts are offset relative to the subscript
-DELTA = 0.18
-
-class MathTextWarning(Warning):
- pass
-
-class Node(object):
- """
- A node in the TeX box model
- """
- def __init__(self):
- self.size = 0
-
- def __repr__(self):
- return self.__internal_repr__()
-
- def __internal_repr__(self):
- return self.__class__.__name__
-
- def get_kerning(self, next):
- return 0.0
-
- def shrink(self):
- """
- Shrinks one level smaller. There are only three levels of
- sizes, after which things will no longer get smaller.
- """
- self.size += 1
-
- def grow(self):
- """
- Grows one level larger. There is no limit to how big
- something can get.
- """
- self.size -= 1
-
- def render(self, x, y):
- pass
-
-class Box(Node):
- """
- Represents any node with a physical location.
- """
- def __init__(self, width, height, depth):
- Node.__init__(self)
- self.width = width
- self.height = height
- self.depth = depth
-
- def shrink(self):
- Node.shrink(self)
- if self.size < NUM_SIZE_LEVELS:
- self.width *= SHRINK_FACTOR
- self.height *= SHRINK_FACTOR
- self.depth *= SHRINK_FACTOR
-
- def grow(self):
- Node.grow(self)
- self.width *= GROW_FACTOR
- self.height *= GROW_FACTOR
- self.depth *= GROW_FACTOR
-
- def render(self, x1, y1, x2, y2):
- pass
-
-class Vbox(Box):
- """
- A box with only height (zero width).
- """
- def __init__(self, height, depth):
- Box.__init__(self, 0., height, depth)
-
-class Hbox(Box):
- """
- A box with only width (zero height and depth).
- """
- def __init__(self, width):
- Box.__init__(self, width, 0., 0.)
-
-class Char(Node):
- """
- Represents a single character. Unlike TeX, the font information
- and metrics are stored with each :class:`Char` to make it easier
- to lookup the font metrics when needed. Note that TeX boxes have
- a width, height, and depth, unlike Type1 and Truetype which use a
- full bounding box and an advance in the x-direction. The metrics
- must be converted to the TeX way, and the advance (if different
- from width) must be converted into a :class:`Kern` node when the
- :class:`Char` is added to its parent :class:`Hlist`.
- """
- def __init__(self, c, state):
- Node.__init__(self)
- self.c = c
- self.font_output = state.font_output
- assert isinstance(state.font, (str, unicode, int))
- self.font = state.font
- self.font_class = state.font_class
- self.fontsize = state.fontsize
- self.dpi = state.dpi
- # The real width, height and depth will be set during the
- # pack phase, after we know the real fontsize
- self._update_metrics()
-
- def __internal_repr__(self):
- return '`%s`' % self.c
-
- def _update_metrics(self):
- metrics = self._metrics = self.font_output.get_metrics(
- self.font, self.font_class, self.c, self.fontsize, self.dpi)
- if self.c == ' ':
- self.width = metrics.advance
- else:
- self.width = metrics.width
- self.height = metrics.iceberg
- self.depth = -(metrics.iceberg - metrics.height)
-
- def is_slanted(self):
- return self._metrics.slanted
-
- def get_kerning(self, next):
- """
- Return the amount of kerning between this and the given
- character. Called when characters are strung together into
- :class:`Hlist` to create :class:`Kern` nodes.
- """
- advance = self._metrics.advance - self.width
- kern = 0.
- if isinstance(next, Char):
- kern = self.font_output.get_kern(
- self.font, self.font_class, self.c, self.fontsize,
- next.font, next.font_class, next.c, next.fontsize,
- self.dpi)
- return advance + kern
-
- def render(self, x, y):
- """
- Render the character to the canvas
- """
- self.font_output.render_glyph(
- x, y,
- self.font, self.font_class, self.c, self.fontsize, self.dpi)
-
- def shrink(self):
- Node.shrink(self)
- if self.size < NUM_SIZE_LEVELS:
- self.fontsize *= SHRINK_FACTOR
- self.width *= SHRINK_FACTOR
- self.height *= SHRINK_FACTOR
- self.depth *= SHRINK_FACTOR
-
- def grow(self):
- Node.grow(self)
- self.fontsize *= GROW_FACTOR
- self.width *= GROW_FACTOR
- self.height *= GROW_FACTOR
- self.depth *= GROW_FACTOR
-
-class Accent(Char):
- """
- The font metrics need to be dealt with differently for accents,
- since they are already offset correctly from the baseline in
- TrueType fonts.
- """
- def _update_metrics(self):
- metrics = self._metrics = self.font_output.get_metrics(
- self.font, self.font_class, self.c, self.fontsize, self.dpi)
- self.width = metrics.xmax - metrics.xmin
- self.height = metrics.ymax - metrics.ymin
- self.depth = 0
-
- def shrink(self):
- Char.shrink(self)
- self._update_metrics()
-
- def grow(self):
- Char.grow(self)
- self._update_metrics()
-
- def render(self, x, y):
- """
- Render the character to the canvas.
- """
- self.font_output.render_glyph(
- x - self._metrics.xmin, y + self._metrics.ymin,
- self.font, self.font_class, self.c, self.fontsize, self.dpi)
-
-class List(Box):
- """
- A list of nodes (either horizontal or vertical).
- """
- def __init__(self, elements):
- Box.__init__(self, 0., 0., 0.)
- self.shift_amount = 0. # An arbitrary offset
- self.children = elements # The child nodes of this list
- # The following parameters are set in the vpack and hpack functions
- self.glue_set = 0. # The glue setting of this list
- self.glue_sign = 0 # 0: normal, -1: shrinking, 1: stretching
- self.glue_order = 0 # The order of infinity (0 - 3) for the glue
-
- def __repr__(self):
- return '[%s <%.02f %.02f %.02f %.02f> %s]' % (
- self.__internal_repr__(),
- self.width, self.height,
- self.depth, self.shift_amount,
- ' '.join([repr(x) for x in self.children]))
-
- def _determine_order(self, totals):
- """
- A helper function to determine the highest order of glue
- used by the members of this list. Used by vpack and hpack.
- """
- o = 0
- for i in range(len(totals) - 1, 0, -1):
- if totals[i] != 0.0:
- o = i
- break
- return o
-
- def _set_glue(self, x, sign, totals, error_type):
- o = self._determine_order(totals)
- self.glue_order = o
- self.glue_sign = sign
- if totals[o] != 0.:
- self.glue_set = x / totals[o]
- else:
- self.glue_sign = 0
- self.glue_ratio = 0.
- if o == 0:
- if len(self.children):
- warn("%s %s: %r" % (error_type, self.__class__.__name__, self),
- MathTextWarning)
-
- def shrink(self):
- for child in self.children:
- child.shrink()
- Box.shrink(self)
- if self.size < NUM_SIZE_LEVELS:
- self.shift_amount *= SHRINK_FACTOR
- self.glue_set *= SHRINK_FACTOR
-
- def grow(self):
- for child in self.children:
- child.grow()
- Box.grow(self)
- self.shift_amount *= GROW_FACTOR
- self.glue_set *= GROW_FACTOR
-
-class Hlist(List):
- """
- A horizontal list of boxes.
- """
- def __init__(self, elements, w=0., m='additional', do_kern=True):
- List.__init__(self, elements)
- if do_kern:
- self.kern()
- self.hpack()
-
- def kern(self):
- """
- Insert :class:`Kern` nodes between :class:`Char` nodes to set
- kerning. The :class:`Char` nodes themselves determine the
- amount of kerning they need (in :meth:`~Char.get_kerning`),
- and this function just creates the linked list in the correct
- way.
- """
- new_children = []
- num_children = len(self.children)
- if num_children:
- for i in range(num_children):
- elem = self.children[i]
- if i < num_children - 1:
- next = self.children[i + 1]
- else:
- next = None
-
- new_children.append(elem)
- kerning_distance = elem.get_kerning(next)
- if kerning_distance != 0.:
- kern = Kern(kerning_distance)
- new_children.append(kern)
- self.children = new_children
-
- # This is a failed experiment to fake cross-font kerning.
-# def get_kerning(self, next):
-# if len(self.children) >= 2 and isinstance(self.children[-2], Char):
-# if isinstance(next, Char):
-# print "CASE A"
-# return self.children[-2].get_kerning(next)
-# elif isinstance(next, Hlist) and len(next.children) and isinstance(next.children[0], Char):
-# print "CASE B"
-# result = self.children[-2].get_kerning(next.children[0])
-# print result
-# return result
-# return 0.0
-
- def hpack(self, w=0., m='additional'):
- """
- The main duty of :meth:`hpack` is to compute the dimensions of
- the resulting boxes, and to adjust the glue if one of those
- dimensions is pre-specified. The computed sizes normally
- enclose all of the material inside the new box; but some items
- may stick out if negative glue is used, if the box is
- overfull, or if a ``\\vbox`` includes other boxes that have
- been shifted left.
-
- - *w*: specifies a width
-
- - *m*: is either 'exactly' or 'additional'.
-
- Thus, ``hpack(w, 'exactly')`` produces a box whose width is
- exactly *w*, while ``hpack(w, 'additional')`` yields a box
- whose width is the natural width plus *w*. The default values
- produce a box with the natural width.
- """
- # I don't know why these get reset in TeX. Shift_amount is pretty
- # much useless if we do.
- #self.shift_amount = 0.
- h = 0.
- d = 0.
- x = 0.
- total_stretch = [0.] * 4
- total_shrink = [0.] * 4
- for p in self.children:
- if isinstance(p, Char):
- x += p.width
- h = max(h, p.height)
- d = max(d, p.depth)
- elif isinstance(p, Box):
- x += p.width
- if not isinf(p.height) and not isinf(p.depth):
- s = getattr(p, 'shift_amount', 0.)
- h = max(h, p.height - s)
- d = max(d, p.depth + s)
- elif isinstance(p, Glue):
- glue_spec = p.glue_spec
- x += glue_spec.width
- total_stretch[glue_spec.stretch_order] += glue_spec.stretch
- total_shrink[glue_spec.shrink_order] += glue_spec.shrink
- elif isinstance(p, Kern):
- x += p.width
- self.height = h
- self.depth = d
-
- if m == 'additional':
- w += x
- self.width = w
- x = w - x
-
- if x == 0.:
- self.glue_sign = 0
- self.glue_order = 0
- self.glue_ratio = 0.
- return
- if x > 0.:
- self._set_glue(x, 1, total_stretch, "Overfull")
- else:
- self._set_glue(x, -1, total_shrink, "Underfull")
-
-class Vlist(List):
- """
- A vertical list of boxes.
- """
- def __init__(self, elements, h=0., m='additional'):
- List.__init__(self, elements)
- self.vpack()
-
- def vpack(self, h=0., m='additional', l=float(inf)):
- """
- The main duty of :meth:`vpack` is to compute the dimensions of
- the resulting boxes, and to adjust the glue if one of those
- dimensions is pre-specified.
-
- - *h*: specifies a height
- - *m*: is either 'exactly' or 'additional'.
- - *l*: a maximum height
-
- Thus, ``vpack(h, 'exactly')`` produces a box whose height is
- exactly *h*, while ``vpack(h, 'additional')`` yields a box
- whose height is the natural height plus *h*. The default
- values produce a box with the natural width.
- """
- # I don't know why these get reset in TeX. Shift_amount is pretty
- # much useless if we do.
- # self.shift_amount = 0.
- w = 0.
- d = 0.
- x = 0.
- total_stretch = [0.] * 4
- total_shrink = [0.] * 4
- for p in self.children:
- if isinstance(p, Box):
- x += d + p.height
- d = p.depth
- if not isinf(p.width):
- s = getattr(p, 'shift_amount', 0.)
- w = max(w, p.width + s)
- elif isinstance(p, Glue):
- x += d
- d = 0.
- glue_spec = p.glue_spec
- x += glue_spec.width
- total_stretch[glue_spec.stretch_order] += glue_spec.stretch
- total_shrink[glue_spec.shrink_order] += glue_spec.shrink
- elif isinstance(p, Kern):
- x += d + p.width
- d = 0.
- elif isinstance(p, Char):
- raise RuntimeError("Internal mathtext error: Char node found in Vlist.")
-
- self.width = w
- if d > l:
- x += d - l
- self.depth = l
- else:
- self.depth = d
-
- if m == 'additional':
- h += x
- self.height = h
- x = h - x
-
- if x == 0:
- self.glue_sign = 0
- self.glue_order = 0
- self.glue_ratio = 0.
- return
-
- if x > 0.:
- self._set_glue(x, 1, total_stretch, "Overfull")
- else:
- self._set_glue(x, -1, total_shrink, "Underfull")
-
-class Rule(Box):
- """
- A :class:`Rule` node stands for a solid black rectangle; it has
- *width*, *depth*, and *height* fields just as in an
- :class:`Hlist`. However, if any of these dimensions is inf, the
- actual value will be determined by running the rule up to the
- boundary of the innermost enclosing box. This is called a "running
- dimension." The width is never running in an :class:`Hlist`; the
- height and depth are never running in a :class:`Vlist`.
- """
- def __init__(self, width, height, depth, state):
- Box.__init__(self, width, height, depth)
- self.font_output = state.font_output
-
- def render(self, x, y, w, h):
- self.font_output.render_rect_filled(x, y, x + w, y + h)
-
-class Hrule(Rule):
- """
- Convenience class to create a horizontal rule.
- """
- def __init__(self, state):
- thickness = state.font_output.get_underline_thickness(
- state.font, state.fontsize, state.dpi)
- height = depth = thickness * 0.5
- Rule.__init__(self, inf, height, depth, state)
-
-class Vrule(Rule):
- """
- Convenience class to create a vertical rule.
- """
- def __init__(self, state):
- thickness = state.font_output.get_underline_thickness(
- state.font, state.fontsize, state.dpi)
- Rule.__init__(self, thickness, inf, inf, state)
-
-class Glue(Node):
- """
- Most of the information in this object is stored in the underlying
- :class:`GlueSpec` class, which is shared between multiple glue objects. (This
- is a memory optimization which probably doesn't matter anymore, but it's
- easier to stick to what TeX does.)
- """
- def __init__(self, glue_type, copy=False):
- Node.__init__(self)
- self.glue_subtype = 'normal'
- if is_string_like(glue_type):
- glue_spec = GlueSpec.factory(glue_type)
- elif isinstance(glue_type, GlueSpec):
- glue_spec = glue_type
- else:
- raise ArgumentError("glue_type must be a glue spec name or instance.")
- if copy:
- glue_spec = glue_spec.copy()
- self.glue_spec = glue_spec
-
- def shrink(self):
- Node.shrink(self)
- if self.size < NUM_SIZE_LEVELS:
- if self.glue_spec.width != 0.:
- self.glue_spec = self.glue_spec.copy()
- self.glue_spec.width *= SHRINK_FACTOR
-
- def grow(self):
- Node.grow(self)
- if self.glue_spec.width != 0.:
- self.glue_spec = self.glue_spec.copy()
- self.glue_spec.width *= GROW_FACTOR
-
-class GlueSpec(object):
- """
- See :class:`Glue`.
- """
- def __init__(self, width=0., stretch=0., stretch_order=0, shrink=0., shrink_order=0):
- self.width = width
- s...
[truncated message content] |
|
From: <evi...@us...> - 2009-07-22 13:47:52
|
Revision: 7283
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7283&view=rev
Author: evilguru
Date: 2009-07-22 13:47:42 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Port the OS X backend over. I am unable to test this at the current time.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_macosx.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22 13:08:41 UTC (rev 7282)
+++ branches/mathtex/lib/matplotlib/backends/backend_macosx.py 2009-07-22 13:47:42 UTC (rev 7283)
@@ -9,11 +9,11 @@
from matplotlib.cbook import maxdict
from matplotlib.figure import Figure
from matplotlib.path import Path
-from matplotlib.mathtext import MathTextParser
from matplotlib.colors import colorConverter
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_image import MathtexBackendImage
-
from matplotlib.widgets import SubplotTool
import matplotlib
@@ -77,7 +77,7 @@
nrows, ncols, data = im.as_rgba_str()
self.gc.draw_image(x, y, nrows, ncols, data, bbox, clippath, clippath_trans)
im.flipud_out()
-
+
def draw_tex(self, gc, x, y, s, prop, angle):
# todo, handle props, angle, origins
size = prop.get_size_in_points()
@@ -91,10 +91,12 @@
gc.draw_mathtext(x, y, angle, Z)
def _draw_mathtext(self, gc, x, y, s, prop, angle):
- ox, oy, width, height, descent, image, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- gc.draw_mathtext(x, y, angle, 255 - image.as_array())
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), self.dpi)
+ b = MathtexBackendImage()
+ m.render_to_backend(b)
+ gc.draw_mathtext(x, y, angle, 255 - b.image.as_array())
+
def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
if ismath:
self._draw_mathtext(gc, x, y, s, prop, angle)
@@ -115,9 +117,9 @@
renderer=self)
return w, h, d
if ismath:
- ox, oy, width, height, descent, fonts, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), self.dpi)
+ return m.width, m.height, m.depth
family = prop.get_family()
weight = prop.get_weight()
style = prop.get_style()
@@ -128,7 +130,7 @@
def flipy(self):
return False
-
+
def points_to_pixels(self, points):
return points/72.0 * self.dpi
@@ -168,7 +170,7 @@
_macosx.GraphicsContext.set_clip_path(self, path)
########################################################################
-#
+#
# The following functions and classes are for pylab and implement
# window/figure managers, etc...
#
@@ -281,7 +283,7 @@
self.toolbar = NavigationToolbar2Mac(canvas)
else:
self.toolbar = None
- if self.toolbar is not None:
+ if self.toolbar is not None:
self.toolbar.update()
def notify_axes_change(fig):
@@ -300,7 +302,7 @@
Gcf.destroy(self.num)
class NavigationToolbarMac(_macosx.NavigationToolbar):
-
+
def __init__(self, canvas):
self.canvas = canvas
basedir = os.path.join(matplotlib.rcParams['datapath'], "images")
@@ -331,7 +333,7 @@
assert magic=="P6"
assert len(imagedata)==width*height*3 # 3 colors in RGB
return (width, height, imagedata)
-
+
def panx(self, direction):
axes = self.canvas.figure.axes
selected = self.get_active()
@@ -401,9 +403,9 @@
_macosx.NavigationToolbar2.set_message(self, message.encode('utf-8'))
########################################################################
-#
+#
# Now just provide the standard names that backend.__init__ is expecting
-#
+#
########################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-07-22 13:08:44
|
Revision: 7282
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7282&view=rev
Author: jouni
Date: 2009-07-22 13:08:41 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Improved boilerplate.py so that it generates the correct signatures for pyplot functions.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/boilerplate.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-22 10:54:35 UTC (rev 7281)
+++ trunk/matplotlib/CHANGELOG 2009-07-22 13:08:41 UTC (rev 7282)
@@ -1,3 +1,6 @@
+2009-07-22 Improved boilerplate.py so that it generates the correct
+ signatures for pyplot functions. - JKS
+
2009-07-19 Fixed the docstring of Axes.step to reflect the correct
meaning of the kwargs "pre" and "post" - See SF bug
https://sourceforge.net/tracker/index.php?func=detail&aid=2823304&group_id=80706&atid=560720
Modified: trunk/matplotlib/boilerplate.py
===================================================================
--- trunk/matplotlib/boilerplate.py 2009-07-22 10:54:35 UTC (rev 7281)
+++ trunk/matplotlib/boilerplate.py 2009-07-22 13:08:41 UTC (rev 7282)
@@ -1,47 +1,50 @@
-# wrap the plot commands defined in axes. The code generated by this
+# Wrap the plot commands defined in axes. The code generated by this
# file is pasted into pylab.py. We did try to do this the smart way,
# with callable functions and new.function, but could never get the
# docstrings right for python2.2. See
# http://groups.google.com/group/comp.lang.python/browse_frm/thread/dcd63ec13096a0f6/1b14640f3a4ad3dc?#1b14640f3a4ad3dc
+# For some later history, see
+# http://thread.gmane.org/gmane.comp.python.matplotlib.devel/7068
+import inspect
+import random
+import re
+import sys
+import types
-# note we check for __doc__ is not None since py2exe optimize removes
-# the docstrings
+# import the local copy of matplotlib, not the installed one
+sys.path.insert(0, './lib')
+from matplotlib.axes import Axes
+from matplotlib.cbook import dedent
_fmtplot = """\
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def %(func)s(*args, **kwargs):
+def %(func)s(%(argspec)s):
+ %(docstring)s
+ %(ax)s = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ %(washold)s = %(ax)s.ishold()
+ %(sethold)s
+ if hold is not None:
+ %(ax)s.hold(hold)
try:
- ret = gca().%(func)s(*args, **kwargs)
+ %(ret)s = %(ax)s.%(func)s(%(call)s)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ %(ax)s.hold(%(washold)s)
%(mappable)s
- hold(b)
- return ret
-if Axes.%(func)s.__doc__ is not None:
- %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__) + \"\"\"
-
-Additional kwargs: hold = [True|False] overrides default hold state\"\"\"
+ return %(ret)s
"""
_fmtmisc = """\
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def %(func)s(*args, **kwargs):
-
- ret = gca().%(func)s(*args, **kwargs)
+def %(func)s(%(argspec)s):
+ %(docstring)s
+ %(ret)s = gca().%(func)s(%(call)s)
draw_if_interactive()
- return ret
-if Axes.%(func)s.__doc__ is not None:
- %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__)
+ return %(ret)s
"""
# these methods are all simple wrappers of Axes methods by the same
@@ -101,33 +104,113 @@
)
cmappable = {
- 'contour' : 'if ret._A is not None: gci._current = ret',
- 'contourf': 'if ret._A is not None: gci._current = ret',
- 'hexbin' : 'gci._current = ret[0]',
- 'scatter' : 'gci._current = ret',
- 'pcolor' : 'gci._current = ret',
- 'pcolormesh' : 'gci._current = ret',
- 'imshow' : 'gci._current = ret',
- 'spy' : 'gci._current = ret',
- 'quiver' : 'gci._current = ret',
- 'specgram' : 'gci._current = ret[-1]',
+ 'contour' : 'if %(ret)s._A is not None: gci._current = %(ret)s',
+ 'contourf': 'if %(ret)s._A is not None: gci._current = %(ret)s',
+ 'hexbin' : 'gci._current = %(ret)s',
+ 'scatter' : 'gci._current = %(ret)s',
+ 'pcolor' : 'gci._current = %(ret)s',
+ 'pcolormesh' : 'gci._current = %(ret)s',
+ 'imshow' : 'gci._current = %(ret)s',
+ 'spy' : 'gci._current = %(ret)s',
+ 'quiver' : 'gci._current = %(ret)s',
+ 'specgram' : 'gci._current = %(ret)s[-1]',
}
+def format_value(value):
+ """
+ Format function default values as needed for inspect.formatargspec.
+ The interesting part is a hard-coded list of functions used
+ as defaults in pyplot methods.
+ """
+ if isinstance(value, types.FunctionType):
+ if value.func_name in ('detrend_none', 'window_hanning'):
+ return '=mlab.' + value.func_name
+ if value.func_name == 'mean':
+ return '=np.' + value.func_name
+ raise ValueError, ('default value %s unknown to boilerplate.formatvalue'
+ % value)
+ return '='+repr(value)
-for func in _plotcommands:
- if func in cmappable:
- mappable = cmappable[func]
- else:
- mappable = ''
- print _fmtplot%locals()
+def remove_final_whitespace(string):
+ """
+ Return a copy of *string* with final whitespace removed from each line.
+ """
+ return '\n'.join(x.rstrip() for x in string.split('\n'))
+def make_docstring(cmd, mention_hold):
+ func = getattr(Axes, cmd)
+ docstring = inspect.getdoc(func)
+ if docstring is None:
+ return ""
+ escaped = re.sub(r'\\', r'\\\\', docstring)
+ if mention_hold:
+ escaped += '''
-for func in _misccommands:
- print _fmtmisc%locals()
+Additional kwargs: hold = [True|False] overrides default hold state
+'''
+ return '"""'+escaped+'"""'
+for fmt,cmdlist in (_fmtplot,_plotcommands),(_fmtmisc,_misccommands):
+ for func in cmdlist:
+ # For some commands, an additional line is needed to set the
+ # color map
+ if func in cmappable:
+ mappable = cmappable[func] % locals()
+ else:
+ mappable = ''
+ # Format docstring
+ docstring = make_docstring(func, fmt is _fmtplot)
+ # Get argspec of wrapped function
+ args, varargs, varkw, defaults = inspect.getargspec(getattr(Axes, func))
+ args.pop(0) # remove 'self' argument
+ if defaults is None:
+ defaults = ()
+
+ # How to call the wrapped function
+ call = map(str, args)
+ if varargs is not None:
+ call.append('*'+varargs)
+ if varkw is not None:
+ call.append('**'+varkw)
+ call = ', '.join(call)
+
+ # Add a hold keyword argument if needed (fmt is _fmtplot) and
+ # possible (if *args is used, we can't just add a hold
+ # argument in front of it since it would gobble one of the
+ # arguments the user means to pass via *args)
+ if varargs:
+ sethold = "hold = %(varkw)s.pop('hold', None)" % locals()
+ elif fmt is _fmtplot:
+ args.append('hold')
+ defaults = defaults + (None,)
+ sethold = ''
+
+ # Now we can build the argspec for defining the wrapper
+ argspec = inspect.formatargspec(args, varargs, varkw, defaults,
+ formatvalue=format_value)
+ argspec = argspec[1:-1] # remove parens
+
+ # A gensym-like facility in case some function takes an
+ # argument named washold, ax, or ret
+ washold,ret,ax = 'washold', 'ret', 'ax'
+ bad = set(args) | set((varargs, varkw))
+ while washold in bad or ret in bad or ax in bad:
+ washold = 'washold' + str(random.randrange(10**12))
+ ret = 'ret' + str(random.randrange(10**12))
+ ax = 'ax' + str(random.randrange(10**12))
+
+ # Since we can't avoid using some function names,
+ # bail out if they are used as argument names
+ for reserved in ('gca', 'gci', 'draw_if_interactive'):
+ if reserved in bad:
+ raise ValueError, \
+ 'Axes method %s has kwarg named %s' % (func, reserved)
+
+ print remove_final_whitespace(fmt%locals())
+
# define the colormap functions
_fmtcmap = """\
# This function was autogenerated by boilerplate.py. Do not edit as
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2009-07-22 10:54:35 UTC (rev 7281)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2009-07-22 13:08:41 UTC (rev 7282)
@@ -13,12 +13,14 @@
from matplotlib.artist import setp as _setp
from matplotlib.axes import Axes
from matplotlib.projections import PolarAxes
-from matplotlib import mlab # for csv2rec in plotfile
+from matplotlib import mlab # for csv2rec, detrend_none, window_hanning
from matplotlib.scale import get_scale_docs, get_scale_names
from matplotlib import cm
from matplotlib.cm import get_cmap
+import numpy as np
+
# We may not need the following imports here:
from matplotlib.colors import Normalize, normalize # latter for backwards compat.
from matplotlib.lines import Line2D
@@ -1593,987 +1595,5048 @@
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def acorr(*args, **kwargs):
+def acorr(x, hold=None, **kwargs):
+ """call signature::
+
+ acorr(x, normed=True, detrend=mlab.detrend_none, usevlines=True,
+ maxlags=10, **kwargs)
+
+Plot the autocorrelation of *x*. If *normed* = *True*,
+normalize the data by the autocorrelation at 0-th lag. *x* is
+detrended by the *detrend* callable (default no normalization).
+
+Data are plotted as ``plot(lags, c, **kwargs)``
+
+Return value is a tuple (*lags*, *c*, *line*) where:
+
+ - *lags* are a length 2*maxlags+1 lag vector
+
+ - *c* is the 2*maxlags+1 auto correlation vector
+
+ - *line* is a :class:`~matplotlib.lines.Line2D` instance
+ returned by :meth:`plot`
+
+The default *linestyle* is None and the default *marker* is
+``'o'``, though these can be overridden with keyword args.
+The cross correlation is performed with
+:func:`numpy.correlate` with *mode* = 2.
+
+If *usevlines* is *True*, :meth:`~matplotlib.axes.Axes.vlines`
+rather than :meth:`~matplotlib.axes.Axes.plot` is used to draw
+vertical lines from the origin to the acorr. Otherwise, the
+plot style is determined by the kwargs, which are
+:class:`~matplotlib.lines.Line2D` properties.
+
+*maxlags* is a positive integer detailing the number of lags
+to show. The default value of *None* will return all
+:math:`2 \\mathrm{len}(x) - 1` lags.
+
+The return value is a tuple (*lags*, *c*, *linecol*, *b*)
+where
+
+- *linecol* is the
+ :class:`~matplotlib.collections.LineCollection`
+
+- *b* is the *x*-axis.
+
+.. seealso::
+
+ :meth:`~matplotlib.axes.Axes.plot` or
+ :meth:`~matplotlib.axes.Axes.vlines`
+ For documentation on valid kwargs.
+
+**Example:**
+
+:func:`~matplotlib.pyplot.xcorr` above, and
+:func:`~matplotlib.pyplot.acorr` below.
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/xcorr_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().acorr(*args, **kwargs)
+ ret = ax.acorr(x, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.acorr.__doc__ is not None:
- acorr.__doc__ = dedent(Axes.acorr.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def arrow(*args, **kwargs):
+def arrow(x, y, dx, dy, hold=None, **kwargs):
+ """call signature::
+
+ arrow(x, y, dx, dy, **kwargs)
+
+Draws arrow on specified axis from (*x*, *y*) to (*x* + *dx*,
+*y* + *dy*).
+
+Optional kwargs control the arrow properties:
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False] or None for default
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color: matplotlib color arg or sequence of rgba tuples
+ contains: a callable function
+ edgecolor or ec: mpl color spec, or None for default, or 'none' for no color
+ facecolor or fc: mpl color spec, or None for default, or 'none' for no color
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fill: [True | False]
+ gid: an id string
+ hatch: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
+ label: any string
+ linestyle or ls: ['solid' | 'dashed' | 'dashdot' | 'dotted']
+ linewidth or lw: float or None for default
+ lod: [True | False]
+ picker: [None|float|boolean|callable]
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ zorder: any number
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/arrow_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().arrow(*args, **kwargs)
+ ret = ax.arrow(x, y, dx, dy, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.arrow.__doc__ is not None:
- arrow.__doc__ = dedent(Axes.arrow.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def axhline(*args, **kwargs):
+def axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs):
+ """call signature::
+
+ axhline(y=0, xmin=0, xmax=1, **kwargs)
+
+Axis Horizontal Line
+
+Draw a horizontal line at *y* from *xmin* to *xmax*. With the
+default values of *xmin* = 0 and *xmax* = 1, this line will
+always span the horizontal extent of the axes, regardless of
+the xlim settings, even if you change them, eg. with the
+:meth:`set_xlim` command. That is, the horizontal extent is
+in axes coords: 0=left, 0.5=middle, 1.0=right but the *y*
+location is in data coordinates.
+
+Return value is the :class:`~matplotlib.lines.Line2D`
+instance. kwargs are the same as kwargs to plot, and can be
+used to control the line properties. Eg.,
+
+* draw a thick red hline at *y* = 0 that spans the xrange
+
+ >>> axhline(linewidth=4, color='r')
+
+* draw a default hline at *y* = 1 that spans the xrange
+
+ >>> axhline(y=1)
+
+* draw a default hline at *y* = .5 that spans the the middle half of
+ the xrange
+
+ >>> axhline(y=.5, xmin=0.25, xmax=0.75)
+
+Valid kwargs are :class:`~matplotlib.lines.Line2D` properties:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False]
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color or c: any matplotlib color
+ contains: a callable function
+ dash_capstyle: ['butt' | 'round' | 'projecting']
+ dash_joinstyle: ['miter' | 'round' | 'bevel']
+ dashes: sequence of on/off ink in points
+ data: 2D array
+ drawstyle: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ]
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top']
+ gid: an id string
+ label: any string
+ linestyle or ls: [ '-' | '--' | '-.' | ':' | 'None' | ' ' | '' ] and any drawstyle in combination with a linestyle, e.g. 'steps--'.
+ linewidth or lw: float value in points
+ lod: [True | False]
+ marker: [ '+' | '*' | ',' | '.' | '1' | '2' | '3' | '4' | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd' | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|' | TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT | 'None' | ' ' | '' ]
+ markeredgecolor or mec: any matplotlib color
+ markeredgewidth or mew: float value in points
+ markerfacecolor or mfc: any matplotlib color
+ markersize or ms: float
+ markevery: None | integer | (startind, stride)
+ picker: float distance in points or callable pick function ``fn(artist, event)``
+ pickradius: float distance in points
+ rasterized: [True | False | None]
+ snap: unknown
+ solid_capstyle: ['butt' | 'round' | 'projecting']
+ solid_joinstyle: ['miter' | 'round' | 'bevel']
+ transform: a :class:`matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ xdata: 1D array
+ ydata: 1D array
+ zorder: any number
+
+.. seealso::
+
+ :meth:`axhspan`
+ for example plot and source code
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().axhline(*args, **kwargs)
+ ret = ax.axhline(y, xmin, xmax, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.axhline.__doc__ is not None:
- axhline.__doc__ = dedent(Axes.axhline.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def axhspan(*args, **kwargs):
+def axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs):
+ """call signature::
+
+ axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs)
+
+Axis Horizontal Span.
+
+*y* coords are in data units and *x* coords are in axes (relative
+0-1) units.
+
+Draw a horizontal span (rectangle) from *ymin* to *ymax*.
+With the default values of *xmin* = 0 and *xmax* = 1, this
+always spans the xrange, regardless of the xlim settings, even
+if you change them, eg. with the :meth:`set_xlim` command.
+That is, the horizontal extent is in axes coords: 0=left,
+0.5=middle, 1.0=right but the *y* location is in data
+coordinates.
+
+Return value is a :class:`matplotlib.patches.Polygon`
+instance.
+
+Examples:
+
+* draw a gray rectangle from *y* = 0.25-0.75 that spans the
+ horizontal extent of the axes
+
+ >>> axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
+
+Valid kwargs are :class:`~matplotlib.patches.Polygon` properties:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False] or None for default
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color: matplotlib color arg or sequence of rgba tuples
+ contains: a callable function
+ edgecolor or ec: mpl color spec, or None for default, or 'none' for no color
+ facecolor or fc: mpl color spec, or None for default, or 'none' for no color
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fill: [True | False]
+ gid: an id string
+ hatch: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
+ label: any string
+ linestyle or ls: ['solid' | 'dashed' | 'dashdot' | 'dotted']
+ linewidth or lw: float or None for default
+ lod: [True | False]
+ picker: [None|float|boolean|callable]
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ zorder: any number
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/axhspan_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().axhspan(*args, **kwargs)
+ ret = ax.axhspan(ymin, ymax, xmin, xmax, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.axhspan.__doc__ is not None:
- axhspan.__doc__ = dedent(Axes.axhspan.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def axvline(*args, **kwargs):
+def axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs):
+ """call signature::
+
+ axvline(x=0, ymin=0, ymax=1, **kwargs)
+
+Axis Vertical Line
+
+Draw a vertical line at *x* from *ymin* to *ymax*. With the
+default values of *ymin* = 0 and *ymax* = 1, this line will
+always span the vertical extent of the axes, regardless of the
+ylim settings, even if you change them, eg. with the
+:meth:`set_ylim` command. That is, the vertical extent is in
+axes coords: 0=bottom, 0.5=middle, 1.0=top but the *x* location
+is in data coordinates.
+
+Return value is the :class:`~matplotlib.lines.Line2D`
+instance. kwargs are the same as kwargs to plot, and can be
+used to control the line properties. Eg.,
+
+* draw a thick red vline at *x* = 0 that spans the yrange
+
+ >>> axvline(linewidth=4, color='r')
+
+* draw a default vline at *x* = 1 that spans the yrange
+
+ >>> axvline(x=1)
+
+* draw a default vline at *x* = .5 that spans the the middle half of
+ the yrange
+
+ >>> axvline(x=.5, ymin=0.25, ymax=0.75)
+
+Valid kwargs are :class:`~matplotlib.lines.Line2D` properties:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False]
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color or c: any matplotlib color
+ contains: a callable function
+ dash_capstyle: ['butt' | 'round' | 'projecting']
+ dash_joinstyle: ['miter' | 'round' | 'bevel']
+ dashes: sequence of on/off ink in points
+ data: 2D array
+ drawstyle: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ]
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top']
+ gid: an id string
+ label: any string
+ linestyle or ls: [ '-' | '--' | '-.' | ':' | 'None' | ' ' | '' ] and any drawstyle in combination with a linestyle, e.g. 'steps--'.
+ linewidth or lw: float value in points
+ lod: [True | False]
+ marker: [ '+' | '*' | ',' | '.' | '1' | '2' | '3' | '4' | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd' | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|' | TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT | 'None' | ' ' | '' ]
+ markeredgecolor or mec: any matplotlib color
+ markeredgewidth or mew: float value in points
+ markerfacecolor or mfc: any matplotlib color
+ markersize or ms: float
+ markevery: None | integer | (startind, stride)
+ picker: float distance in points or callable pick function ``fn(artist, event)``
+ pickradius: float distance in points
+ rasterized: [True | False | None]
+ snap: unknown
+ solid_capstyle: ['butt' | 'round' | 'projecting']
+ solid_joinstyle: ['miter' | 'round' | 'bevel']
+ transform: a :class:`matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ xdata: 1D array
+ ydata: 1D array
+ zorder: any number
+
+.. seealso::
+
+ :meth:`axhspan`
+ for example plot and source code
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().axvline(*args, **kwargs)
+ ret = ax.axvline(x, ymin, ymax, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.axvline.__doc__ is not None:
- axvline.__doc__ = dedent(Axes.axvline.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def axvspan(*args, **kwargs):
+def axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs):
+ """call signature::
+
+ axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)
+
+Axis Vertical Span.
+
+*x* coords are in data units and *y* coords are in axes (relative
+0-1) units.
+
+Draw a vertical span (rectangle) from *xmin* to *xmax*. With
+the default values of *ymin* = 0 and *ymax* = 1, this always
+spans the yrange, regardless of the ylim settings, even if you
+change them, eg. with the :meth:`set_ylim` command. That is,
+the vertical extent is in axes coords: 0=bottom, 0.5=middle,
+1.0=top but the *y* location is in data coordinates.
+
+Return value is the :class:`matplotlib.patches.Polygon`
+instance.
+
+Examples:
+
+* draw a vertical green translucent rectangle from x=1.25 to 1.55 that
+ spans the yrange of the axes
+
+ >>> axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
+
+Valid kwargs are :class:`~matplotlib.patches.Polygon`
+properties:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False] or None for default
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color: matplotlib color arg or sequence of rgba tuples
+ contains: a callable function
+ edgecolor or ec: mpl color spec, or None for default, or 'none' for no color
+ facecolor or fc: mpl color spec, or None for default, or 'none' for no color
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fill: [True | False]
+ gid: an id string
+ hatch: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
+ label: any string
+ linestyle or ls: ['solid' | 'dashed' | 'dashdot' | 'dotted']
+ linewidth or lw: float or None for default
+ lod: [True | False]
+ picker: [None|float|boolean|callable]
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ zorder: any number
+
+.. seealso::
+
+ :meth:`axhspan`
+ for example plot and source code
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().axvspan(*args, **kwargs)
+ ret = ax.axvspan(xmin, xmax, ymin, ymax, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.axvspan.__doc__ is not None:
- axvspan.__doc__ = dedent(Axes.axvspan.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def bar(*args, **kwargs):
+def bar(left, height, width=0.80000000000000004, bottom=None, color=None, edgecolor=None, linewidth=None, yerr=None, xerr=None, ecolor=None, capsize=3, align='edge', orientation='vertical', log=False, hold=None, **kwargs):
+ """call signature::
+
+ bar(left, height, width=0.8, bottom=0,
+ color=None, edgecolor=None, linewidth=None,
+ yerr=None, xerr=None, ecolor=None, capsize=3,
+ align='edge', orientation='vertical', log=False)
+
+Make a bar plot with rectangles bounded by:
+
+ *left*, *left* + *width*, *bottom*, *bottom* + *height*
+ (left, right, bottom and top edges)
+
+*left*, *height*, *width*, and *bottom* can be either scalars
+or sequences
+
+Return value is a list of
+:class:`matplotlib.patches.Rectangle` instances.
+
+Required arguments:
+
+ ======== ===============================================
+ Argument Description
+ ======== ===============================================
+ *left* the x coordinates of the left sides of the bars
+ *height* the heights of the bars
+ ======== ===============================================
+
+Optional keyword arguments:
+
+ =============== ==========================================
+ Keyword Description
+ =============== ==========================================
+ *width* the widths of the bars
+ *bottom* the y coordinates of the bottom edges of
+ the bars
+ *color* the colors of the bars
+ *edgecolor* the colors of the bar edges
+ *linewidth* width of bar edges; None means use default
+ linewidth; 0 means don't draw edges.
+ *xerr* if not None, will be used to generate
+ errorbars on the bar chart
+ *yerr* if not None, will be used to generate
+ errorbars on the bar chart
+ *ecolor* specifies the color of any errorbar
+ *capsize* (default 3) determines the length in
+ points of the error bar caps
+ *align* 'edge' (default) | 'center'
+ *orientation* 'vertical' | 'horizontal'
+ *log* [False|True] False (default) leaves the
+ orientation axis as-is; True sets it to
+ log scale
+ =============== ==========================================
+
+For vertical bars, *align* = 'edge' aligns bars by their left
+edges in left, while *align* = 'center' interprets these
+values as the *x* coordinates of the bar centers. For
+horizontal bars, *align* = 'edge' aligns bars by their bottom
+edges in bottom, while *align* = 'center' interprets these
+values as the *y* coordinates of the bar centers.
+
+The optional arguments *color*, *edgecolor*, *linewidth*,
+*xerr*, and *yerr* can be either scalars or sequences of
+length equal to the number of bars. This enables you to use
+bar as the basis for stacked bar charts, or candlestick plots.
+
+Other optional kwargs:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False] or None for default
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color: matplotlib color arg or sequence of rgba tuples
+ contains: a callable function
+ edgecolor or ec: mpl color spec, or None for default, or 'none' for no color
+ facecolor or fc: mpl color spec, or None for default, or 'none' for no color
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fill: [True | False]
+ gid: an id string
+ hatch: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
+ label: any string
+ linestyle or ls: ['solid' | 'dashed' | 'dashdot' | 'dotted']
+ linewidth or lw: float or None for default
+ lod: [True | False]
+ picker: [None|float|boolean|callable]
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ zorder: any number
+
+**Example:** A stacked bar chart.
+
+.. plot:: mpl_examples/pylab_examples/bar_stacked.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().bar(*args, **kwargs)
+ ret = ax.bar(left, height, width, bottom, color, edgecolor, linewidth, yerr, xerr, ecolor, capsize, align, orientation, log, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.bar.__doc__ is not None:
- bar.__doc__ = dedent(Axes.bar.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def barh(*args, **kwargs):
+def barh(bottom, width, height=0.80000000000000004, left=None, hold=None, **kwargs):
+ """call signature::
+
+ barh(bottom, width, height=0.8, left=0, **kwargs)
+
+Make a horizontal bar plot with rectangles bounded by:
+
+ *left*, *left* + *width*, *bottom*, *bottom* + *height*
+ (left, right, bottom and top edges)
+
+*bottom*, *width*, *height*, and *left* can be either scalars
+or sequences
+
+Return value is a list of
+:class:`matplotlib.patches.Rectangle` instances.
+
+Required arguments:
+
+ ======== ======================================================
+ Argument Description
+ ======== ======================================================
+ *bottom* the vertical positions of the bottom edges of the bars
+ *width* the lengths of the bars
+ ======== ======================================================
+
+Optional keyword arguments:
+
+ =============== ==========================================
+ Keyword Description
+ =============== ==========================================
+ *height* the heights (thicknesses) of the bars
+ *left* the x coordinates of the left edges of the
+ bars
+ *color* the colors of the bars
+ *edgecolor* the colors of the bar edges
+ *linewidth* width of bar edges; None means use default
+ linewidth; 0 means don't draw edges.
+ *xerr* if not None, will be used to generate
+ errorbars on the bar chart
+ *yerr* if not None, will be used to generate
+ errorbars on the bar chart
+ *ecolor* specifies the color of any errorbar
+ *capsize* (default 3) determines the length in
+ points of the error bar caps
+ *align* 'edge' (default) | 'center'
+ *log* [False|True] False (default) leaves the
+ horizontal axis as-is; True sets it to log
+ scale
+ =============== ==========================================
+
+Setting *align* = 'edge' aligns bars by their bottom edges in
+bottom, while *align* = 'center' interprets these values as
+the *y* coordinates of the bar centers.
+
+The optional arguments *color*, *edgecolor*, *linewidth*,
+*xerr*, and *yerr* can be either scalars or sequences of
+length equal to the number of bars. This enables you to use
+barh as the basis for stacked bar charts, or candlestick
+plots.
+
+other optional kwargs:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False] or None for default
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color: matplotlib color arg or sequence of rgba tuples
+ contains: a callable function
+ edgecolor or ec: mpl color spec, or None for default, or 'none' for no color
+ facecolor or fc: mpl color spec, or None for default, or 'none' for no color
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fill: [True | False]
+ gid: an id string
+ hatch: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
+ label: any string
+ linestyle or ls: ['solid' | 'dashed' | 'dashdot' | 'dotted']
+ linewidth or lw: float or None for default
+ lod: [True | False]
+ picker: [None|float|boolean|callable]
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ zorder: any number
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().barh(*args, **kwargs)
+ ret = ax.barh(bottom, width, height, left, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.barh.__doc__ is not None:
- barh.__doc__ = dedent(Axes.barh.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def broken_barh(*args, **kwargs):
+def broken_barh(xranges, yrange, hold=None, **kwargs):
+ """call signature::
+
+ broken_barh(self, xranges, yrange, **kwargs)
+
+A collection of horizontal bars spanning *yrange* with a sequence of
+*xranges*.
+
+Required arguments:
+
+ ========= ==============================
+ Argument Description
+ ========= ==============================
+ *xranges* sequence of (*xmin*, *xwidth*)
+ *yrange* sequence of (*ymin*, *ywidth*)
+ ========= ==============================
+
+kwargs are
+:class:`matplotlib.collections.BrokenBarHCollection`
+properties:
+
+ alpha: float
+ animated: [True | False]
+ antialiased or antialiaseds: Boolean or sequence of booleans
+ array: unknown
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clim: a length 2 sequence of floats
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ cmap: a colormap
+ color: matplotlib color arg or sequence of rgba tuples
+ colorbar: unknown
+ contains: a callable function
+ edgecolor or edgecolors: matplotlib color arg or sequence of rgba tuples
+ facecolor or facecolors: matplotlib color arg or sequence of rgba tuples
+ figure: a :class:`matplotlib.figure.Figure` instance
+ gid: an id string
+ label: any string
+ linestyle or linestyles or dashes: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) ]
+ linewidth or lw or linewidths: float or sequence of floats
+ lod: [True | False]
+ norm: unknown
+ offsets: float or sequence of floats
+ picker: [None|float|boolean|callable]
+ pickradius: unknown
+ rasterized: [True | False | None]
+ snap: unknown
+ transform: :class:`~matplotlib.transforms.Transform` instance
+ url: a url string
+ urls: unknown
+ visible: [True | False]
+ zorder: any number
+
+these can either be a single argument, ie::
+
+ facecolors = 'black'
+
+or a sequence of arguments for the various bars, ie::
+
+ facecolors = ('black', 'red', 'green')
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/broken_barh.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().broken_barh(*args, **kwargs)
+ ret = ax.broken_barh(xranges, yrange, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.broken_barh.__doc__ is not None:
- broken_barh.__doc__ = dedent(Axes.broken_barh.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def boxplot(*args, **kwargs):
+def boxplot(x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None, hold=None):
+ """call signature::
+
+ boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
+ positions=None, widths=None)
+
+Make a box and whisker plot for each column of *x* or each
+vector in sequence *x*. The box extends from the lower to
+upper quartile values of the data, with a line at the median.
+The whiskers extend from the box to show the range of the
+data. Flier points are those past the end of the whiskers.
+
+- *notch* = 0 (default) produces a rectangular box plot.
+- *notch* = 1 will produce a notched box plot
+
+*sym* (default 'b+') is the default symbol for flier points.
+Enter an empty string ('') if you don't want to show fliers.
+
+- *vert* = 1 (default) makes the boxes vertical.
+- *vert* = 0 makes horizontal boxes. This seems goofy, but
+ that's how Matlab did it.
+
+*whis* (default 1.5) defines the length of the whiskers as
+a function of the inner quartile range. They extend to the
+most extreme data point within ( ``whis*(75%-25%)`` ) data range.
+
+*positions* (default 1,2,...,n) sets the horizontal positions of
+the boxes. The ticks and limits are automatically set to match
+the positions.
+
+*widths* is either a scalar or a vector and sets the width of
+each box. The default is 0.5, or ``0.15*(distance between extreme
+positions)`` if that is smaller.
+
+*x* is an array or a sequence of vectors.
+
+Returns a dictionary mapping each component of the boxplot
+to a list of the :class:`matplotlib.lines.Line2D`
+instances created.
+
+**Example:**
+
+.. plot:: pyplots/boxplot_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().boxplot(*args, **kwargs)
+ ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.boxplot.__doc__ is not None:
- boxplot.__doc__ = dedent(Axes.boxplot.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def cohere(*args, **kwargs):
+def cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, hold=None, **kwargs):
+ """call signature::
+
+ cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
+ window = mlab.window_hanning, noverlap=0, pad_to=None,
+ sides='default', scale_by_freq=None, **kwargs)
+
+cohere the coherence between *x* and *y*. Coherence is the normalized
+cross spectral density:
+
+.. math::
+
+ C_{xy} = \\frac{|P_{xy}|^2}{P_{xx}P_{yy}}
+
+Keyword arguments:
+
+ *NFFT*: integer
+ The number of data points used in each block for the FFT.
+ Must be even; a power 2 is most efficient. The default value is 256.
+
+ *Fs*: scalar
+ The sampling frequency (samples per time unit). It is used
+ to calculate the Fourier frequencies, freqs, in cycles per time
+ unit. The default value is 2.
+
+ *detrend*: callable
+ The function applied to each segment before fft-ing,
+ designed to remove the mean or linear trend. Unlike in
+ matlab, where the *detrend* parameter is a vector, in
+ matplotlib is it a function. The :mod:`~matplotlib.pylab`
+ module defines :func:`~matplotlib.pylab.detrend_none`,
+ :func:`~matplotlib.pylab.detrend_mean`, and
+ :func:`~matplotlib.pylab.detrend_linear`, but you can use
+ a custom function as well.
+
+ *window*: callable or ndarray
+ A function or a vector of length *NFFT*. To create window
+ vectors see :func:`window_hanning`, :func:`window_none`,
+ :func:`numpy.blackman`, :func:`numpy.hamming`,
+ :func:`numpy.bartlett`, :func:`scipy.signal`,
+ :func:`scipy.signal.get_window`, etc. The default is
+ :func:`window_hanning`. If a function is passed as the
+ argument, it must take a data segment as an argument and
+ return the windowed version of the segment.
+
+ *noverlap*: integer
+ The number of points of overlap between blocks. The default value
+ is 0 (no overlap).
+
+ *pad_to*: integer
+ The number of points to which the data segment is padded when
+ performing the FFT. This can be different from *NFFT*, which
+ specifies the number of data points used. While not increasing
+ the actual resolution of the psd (the minimum distance between
+ resolvable peaks), this can give more points in the plot,
+ allowing for more detail. This corresponds to the *n* parameter
+ in the call to fft(). The default is None, which sets *pad_to*
+ equal to *NFFT*
+
+ *sides*: [ 'default' | 'onesided' | 'twosided' ]
+ Specifies which sides of the PSD to return. Default gives the
+ default behavior, which returns one-sided for real data and both
+ for complex data. 'onesided' forces the return of a one-sided PSD,
+ while 'twosided' forces two-sided.
+
+ *scale_by_freq*: boolean
+ Specifies whether the resulting density values should be scaled
+ by the scaling frequency, which gives density in units of Hz^-1.
+ This allows for integration over the returned frequency values.
+ The default is True for MatLab compatibility.
+
+ *Fc*: integer
+ The center frequency of *x* (defaults to 0), which offsets
+ the x extents of the plot to reflect the frequency range used
+ when a signal is acquired and then filtered and downsampled to
+ baseband.
+
+The return value is a tuple (*Cxy*, *f*), where *f* are the
+frequencies of the coherence vector.
+
+kwargs are applied to the lines.
+
+References:
+
+ * Bendat & Piersol -- Random Data: Analysis and Measurement
+ Procedures, John Wiley & Sons (1986)
+
+kwargs control the :class:`~matplotlib.lines.Line2D`
+properties of the coherence plot:
+
+ alpha: float (0.0 transparent through 1.0 opaque)
+ animated: [True | False]
+ antialiased or aa: [True | False]
+ axes: an :class:`~matplotlib.axes.Axes` instance
+ clip_box: a :class:`matplotlib.transforms.Bbox` instance
+ clip_on: [True | False]
+ clip_path: [ (:class:`~matplotlib.path.Path`, :class:`~matplotlib.transforms.Transform`) | :class:`~matplotlib.patches.Patch` | None ]
+ color or c: any matplotlib color
+ contains: a callable function
+ dash_capstyle: ['butt' | 'round' | 'projecting']
+ dash_joinstyle: ['miter' | 'round' | 'bevel']
+ dashes: sequence of on/off ink in points
+ data: 2D array
+ drawstyle: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ]
+ figure: a :class:`matplotlib.figure.Figure` instance
+ fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top']
+ gid: an id string
+ label: any string
+ linestyle or ls: [ '-' | '--' | '-.' | ':' | 'None' | ' ' | '' ] and any drawstyle in combination with a linestyle, e.g. 'steps--'.
+ linewidth or lw: float value in points
+ lod: [True | False]
+ marker: [ '+' | '*' | ',' | '.' | '1' | '2' | '3' | '4' | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd' | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|' | TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT | 'None' | ' ' | '' ]
+ markeredgecolor or mec: any matplotlib color
+ markeredgewidth or mew: float value in points
+ markerfacecolor or mfc: any matplotlib color
+ markersize or ms: float
+ markevery: None | integer | (startind, stride)
+ picker: float distance in points or callable pick function ``fn(artist, event)``
+ pickradius: float distance in points
+ rasterized: [True | False | None]
+ snap: unknown
+ solid_capstyle: ['butt' | 'round' | 'projecting']
+ solid_joinstyle: ['miter' | 'round' | 'bevel']
+ transform: a :class:`matplotlib.transforms.Transform` instance
+ url: a url string
+ visible: [True | False]
+ xdata: 1D array
+ ydata: 1D array
+ zorder: any number
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/cohere_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().cohere(*args, **kwargs)
+ ret = ax.cohere(x, y, NFFT, Fs, Fc, detrend, window, noverlap, pad_to, sides, scale_by_freq, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.cohere.__doc__ is not None:
- cohere.__doc__ = dedent(Axes.cohere.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
-def clabel(*args, **kwargs):
+def clabel(CS, *args, **kwargs):
+ """call signature::
+
+ clabel(cs, **kwargs)
+
+adds labels to line contours in *cs*, where *cs* is a
+:class:`~matplotlib.contour.ContourSet` object returned by
+contour.
+
+::
+
+ clabel(cs, v, **kwargs)
+
+only labels contours listed in *v*.
+
+Optional keyword arguments:
+
+ *fontsize*:
+ See http://matplotlib.sf.net/fonts.html
+
+ *colors*:
+ - if *None*, the color of each label matches the color of
+ the corresponding contour
+
+ - if one string color, e.g. *colors* = 'r' or *colors* =
+ 'red', all labels will be plotted in this color
+
+ - if a tuple of matplotlib color args (string, float, rgb, etc),
+ different labels will be plotted in different colors in the order
+ specified
+
+ *inline*:
+ controls whether the underlying contour is removed or
+ not. Default is *True*.
+
+ *inline_spacing*:
+ space in pixels to leave on each side of label when
+ placing inline. Defaults to 5. This spacing will be
+ exact for labels at locations where the contour is
+ straight, less so for labels on curved contours.
+
+ *fmt*:
+ a format string for the label. Default is '%1.3f'
+ Alternatively, this can be a dictionary matching contour
+ levels with arbitrary strings to use for each contour level
+ (i.e., fmt[level]=string)
+
+ *manual*:
+ if *True*, contour labels will be placed manually using
+ mouse clicks. Click the first button near a contour to
+ add a label, click the second button (or potentially both
+ mouse buttons at once) to finish adding labels. The third
+ button can be used to remove the last label added, but
+ only if labels are not inline. Alternatively, the keyboard
+ can be used to select label locations (enter to end label
+ placement, delete or backspace act like the third mouse button,
+ and any other key will select a label location).
+
+ *rightside_up*:
+ if *True* (default), label rotations will always be plus
+ or minus 90 degrees from level.
+
+.. plot:: mpl_examples/pylab_examples/contour_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+ hold = kwargs.pop('hold', None)
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().clabel(*args, **kwargs)
+ ret = ax.clabel(CS, *args, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
- hold(b)
return ret
-if Axes.clabel.__doc__ is not None:
- clabel.__doc__ = dedent(Axes.clabel.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will be lost
def contour(*args, **kwargs):
+ """:func:`~matplotlib.pyplot.contour` and
+:func:`~matplotlib.pyplot.contourf` draw contour lines and
+filled contours, respectively. Except as noted, function
+signatures and return values are the same for both versions.
+
+:func:`~matplotlib.pyplot.contourf` differs from the Matlab
+(TM) version in that it does not draw the polygon edges,
+because the contouring engine yields simply connected regions
+with branch cuts. To draw the edges, add line contours with
+calls to :func:`~matplotlib.pyplot.contour`.
+
+
+call signatures::
+
+ contour(Z)
+
+make a contour plot of an array *Z*. The level values are chosen
+automatically.
+
+::
+
+ contour(X,Y,Z)
+
+*X*, *Y* specify the (*x*, *y*) coordinates of the surface
+
+::
+
+ contour(Z,N)
+ contour(X,Y,Z,N)
+
+contour *N* automatically-chosen levels.
+
+::
+
+ contour(Z,V)
+ contour(X,Y,Z,V)
+
+draw contour lines at the values specified in sequence *V*
+
+::
+
+ contourf(..., V)
+
+fill the (len(*V*)-1) regions between the values in *V*
+
+::
+
+ contour(Z, **kwargs)
+
+Use keyword args to control colors, linewidth, origin, cmap ... see
+below for more details.
+
+*X*, *Y*, and *Z* must be arrays with the same dimensions.
+
+*Z* may be a masked array, but filled contouring may not
+handle internal masked regions correctly.
+
+``C = contour(...)`` returns a
+:class:`~matplotlib.contour.ContourSet` object.
+
+Optional keyword arguments:
+
+ *colors*: [ None | string | (mpl_colors) ]
+ If *None*, the colormap specified by cmap will be used.
+
+ If a string, like 'r' or 'red', all levels will be plotted in this
+ color.
+
+ If a tuple of matplotlib color args (string, float, rgb, etc),
+ different levels will be plotted in different colors in the order
+ specified.
+
+ *alpha*: float
+ The alpha blending value
+
+ *cmap*: [ None | Colormap ]
+ A cm :class:`~matplotlib.cm.Colormap` instance or
+ *None*. If *cmap* is *None* and *colors* is *None*, a
+ default Colormap is used.
+
+ *norm*: [ None | Normalize ]
+ A :class:`matplotlib.colors.Normalize` instance for
+ scaling data values to colors. If *norm* is *None* and
+ *colors* is *None*, the default linear scaling is used.
+
+ *origin*: [ None | 'upper' | 'lower' | 'image' ]
+ If *None*, the first value of *Z* will correspond to the
+ lower left corner, location (0,0). If 'image', the rc
+ value for ``image.origin`` will be used.
+
+ This keyword is not active if *X* and *Y* are specified in
+ the call to contour.
+
+ *extent*: [ None | (x0,x1,y0,y1) ]
+
+ If *origin* is not *None*, then *extent* is interpreted as
+ in :func:`matplotlib.pyplot.imshow`: it gives the outer
+ pixel boundaries. In this case, the position of Z[0,0]
+ is the center of the pixel, not a corner. If *origin* is
+ *None*, then (*x0*, *y0*) is the position of Z[0,0], and
+ (*x1*, *y1*) is the position of Z[-1,-1].
+
+ This keyword is not active if *X* and *Y* are specified in
+ the call to contour.
+
+ *locator*: [ None | ticker.Locator subclass ]
+ If *locator* is None, the default
+ :class:`~matplotlib.ticker.MaxNLocator` is used. The
+ locator is used to determine the contour levels if they
+ are not given explicitly via the *V* argument.
+
+ *extend*: [ 'neither' | 'both' | 'min' | 'max' ]
+ Unless this is 'neither', contour levels are automatically
+ added to one or both ends of the range so that all data
+ are included. These added ranges are then mapped to the
+ special colormap values which default to the ends of the
+ colormap range, but can be set via
+ :meth:`matplotlib.cm.Colormap.set_under` and
+ :meth:`matplotlib.cm.Colormap.set_over` methods.
+
+contour-only keyword arguments:
+
+ *linewidths*: [ None | number | tuple of numbers ]
+ If *linewidths* is *None*, the default width in
+ ``lines.linewidth`` in ``matplotlibrc`` is used.
+
+ If a number, all levels will be plotted with this linewidth.
+
+ If a tuple, different levels will be plotted with different
+ linewidths in the order specified
+
+ *linestyles*: [None | 'solid' | 'dashed' | 'dashdot' | 'dotted' ]
+ If *linestyles* is *None*, the 'solid' is used.
+
+ *linestyles* can also be an iterable of the above strings
+ specifying a set of linestyles to be used. If this
+ iterable is shorter than the number of contour levels
+ it will be repeated as necessary.
+
+ If contour is using a monochrome colormap and the contour
+ level is less than 0, then the linestyle specified
+ in ``contour.negative_linestyle`` in ``matplotlibrc``
+ will be used.
+
+contourf-only keyword arguments:
+
+ *antialiased*: [ True | False ]
+ enable antialiasing
+
+ *nchunk*: [ 0 | integer ]
+ If 0, no subdivision of the domain. Specify a positive integer to
+ divide the domain into subdomains of roughly *nchunk* by *nchunk*
+ points. This may never actually be advantageous, so this option may
+ be removed. Chunking introduces artifacts at the chunk boundaries
+ unless *antialiased* is *False*.
+
+**Example:**
+
+.. plot:: mpl_examples/pylab_examples/contour_demo.py
+
+Additional kwargs: hold = [True|False] overrides default hold state
+"""
+ ax = gca()
# allow callers to override the hold state by passing hold=True|False
- b = ishold()
- h = kwargs.pop('hold', None)
- if h is not None:
- hold(h)
+ washold = ax.ishold()
+ hold = kwargs.pop('hold', None)
+ if hold is not None:
+ ax.hold(hold)
try:
- ret = gca().contour(*args, **kwargs)
+ ret = ax.contour(*args, **kwargs)
draw_if_interactive()
- except:
- hold(b)
- raise
+ finally:
+ ax.hold(washold)
if ret._A is not None: gci._current = ret
- hold(b)
return ret
-if Axes.contour.__doc__ is not None:
- contour.__doc__ = dedent(Axes.contour.__doc__) + """
-Additional kwargs: hold = [True|False] overrides default hold state"""
-
# This function was autogenerated by boilerplate.py. Do not edit as
# changes will b...
[truncated message content] |
|
From: <evi...@us...> - 2009-07-22 10:54:42
|
Revision: 7281
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7281&view=rev
Author: evilguru
Date: 2009-07-22 10:54:35 +0000 (Wed, 22 Jul 2009)
Log Message:
-----------
Remove the mathtext include from the Qt3 backend.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_qt.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_qt.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_qt.py 2009-07-21 19:30:28 UTC (rev 7280)
+++ branches/mathtex/lib/matplotlib/backends/backend_qt.py 2009-07-22 10:54:35 UTC (rev 7281)
@@ -10,7 +10,6 @@
FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors
from matplotlib._pylab_helpers import Gcf
from matplotlib.figure import Figure
-from matplotlib.mathtext import MathTextParser
from matplotlib.widgets import SubplotTool
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-21 19:30:34
|
Revision: 7280
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7280&view=rev
Author: evilguru
Date: 2009-07-21 19:30:28 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Port the menu example over to mathtex. Fonts could use some work.
Modified Paths:
--------------
branches/mathtex/examples/widgets/menu.py
Modified: branches/mathtex/examples/widgets/menu.py
===================================================================
--- branches/mathtex/examples/widgets/menu.py 2009-07-21 17:30:20 UTC (rev 7279)
+++ branches/mathtex/examples/widgets/menu.py 2009-07-21 19:30:28 UTC (rev 7280)
@@ -2,11 +2,11 @@
import matplotlib
import matplotlib.colors as colors
import matplotlib.patches as patches
-import matplotlib.mathtext as mathtext
import matplotlib.pyplot as plt
import matplotlib.artist as artist
import matplotlib.image as image
+from mathtex.mathtex_main import Mathtex
class ItemProperties:
def __init__(self, fontsize=14, labelcolor='black', bgcolor='yellow', alpha=1.0):
@@ -19,7 +19,6 @@
self.bgcolor_rgb = colors.colorConverter.to_rgb(bgcolor)
class MenuItem(artist.Artist):
- parser = mathtext.MathTextParser("Bitmap")
padx = 5
pady =5
def __init__(self, fig, labelstr, props=None, hoverprops=None, on_select=None):
@@ -40,8 +39,8 @@
self.on_select = on_select
- x, self.depth = self.parser.to_mask(
- labelstr, fontsize=props.fontsize, dpi=fig.dpi)
+ m = Mathtex(labelstr, fontsize=props.fontsize, dpi=fig.dpi)
+ x, self.depth = m.as_mask(), m.depth
if props.fontsize!=hoverprops.fontsize:
raise NotImplementedError('support for different font sizes not implemented')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ry...@us...> - 2009-07-21 17:30:24
|
Revision: 7279
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7279&view=rev
Author: ryanmay
Date: 2009-07-21 17:30:20 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Add translucent legend example from John Hunter's mailing list example.
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/legend_translucent.py
Added: trunk/matplotlib/examples/pylab_examples/legend_translucent.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/legend_translucent.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/legend_translucent.py 2009-07-21 17:30:20 UTC (rev 7279)
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+#
+# Show how to add a translucent legend
+
+# import pyplot module
+import matplotlib.pyplot as plt
+
+# draw 2 crossing lines
+plt.plot([0,1], label='going up')
+plt.plot([1,0], label='going down')
+
+# add the legend in the middle of the plot
+leg = plt.legend(fancybox=True, loc='center')
+# set the alpha value of the legend: it will be translucent
+leg.get_frame().set_alpha(0.5)
+
+# show the plot
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-21 14:47:26
|
Revision: 7278
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7278&view=rev
Author: evilguru
Date: 2009-07-21 14:47:21 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Fix the alignment issues with the PS backend.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_ps.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-21 08:31:11 UTC (rev 7277)
+++ branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-21 14:47:21 UTC (rev 7278)
@@ -755,7 +755,7 @@
# Glyphs
for ox, oy, info in m.glyphs:
- oy = m.height - oy + info.offset
+ oy = m.height - m.depth - oy + info.offset
postscript_name = info.postscript_name
fontsize = info.fontsize
symbol_name = info.symbol_name
@@ -775,7 +775,7 @@
# Rects
for x1, y1, x2, y2 in m.rects:
- ps = "%f %f %f %f rectfill\n" % (x1, m.height - y2, x2 - x1, y2 - y1)
+ ps = "%f %f %f %f rectfill\n" % (x1, m.height - m.depth - y2, x2 - x1, y2 - y1)
textwriter.write(ps)
self.set_color(*gc.get_rgb())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-21 08:31:16
|
Revision: 7277
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7277&view=rev
Author: evilguru
Date: 2009-07-21 08:31:11 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
No need to import mathtex in the Qt4 backend.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_qt4.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_qt4.py 2009-07-21 08:25:17 UTC (rev 7276)
+++ branches/mathtex/lib/matplotlib/backends/backend_qt4.py 2009-07-21 08:31:11 UTC (rev 7277)
@@ -10,7 +10,6 @@
FigureManagerBase, FigureCanvasBase, NavigationToolbar2, IdleEvent, cursors
from matplotlib._pylab_helpers import Gcf
from matplotlib.figure import Figure
-from matplotlib.mathtext import MathTextParser
from matplotlib.widgets import SubplotTool
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-21 08:25:19
|
Revision: 7276
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7276&view=rev
Author: evilguru
Date: 2009-07-21 08:25:17 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
Port parts of the PS backend over. Alignment still needs to be checked.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_ps.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-20 13:59:03 UTC (rev 7275)
+++ branches/mathtex/lib/matplotlib/backends/backend_ps.py 2009-07-21 08:25:17 UTC (rev 7276)
@@ -27,7 +27,6 @@
from matplotlib.font_manager import findfont, is_opentype_cff_font
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
from matplotlib.ttconv import convert_ttf_to_ps
-from matplotlib.mathtext import MathTextParser
from matplotlib._mathtext_data import uni2type1
from matplotlib.text import Text
from matplotlib.path import Path
@@ -35,6 +34,7 @@
from matplotlib.backends.backend_mixed import MixedModeRenderer
+from mathtex.mathtex_main import Mathtex
import numpy as npy
import binascii
@@ -168,7 +168,6 @@
self._path_collection_id = 0
self.used_characters = {}
- self.mathtext_parser = MathTextParser("PS")
def track_characters(self, font, s):
"""Keeps track of which characters are required from
@@ -278,9 +277,8 @@
return w, h, d
if ismath:
- width, height, descent, pswriter, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), 72.0)
+ return m.width, m.height, m.depth
if rcParams['ps.useafm']:
if ismath: s = s[1:-1]
@@ -741,11 +739,47 @@
if debugPS:
self._pswriter.write("% mathtext\n")
- width, height, descent, pswriter, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), 72.0)
+
+ # Generate the dict of used characters
+ used_characters = {}
+ for ox, oy, info in m.glyphs:
+ realpath, stat_key = get_realpath_and_stat(info.font.fname)
+ used_font = used_characters.setdefault(stat_key, (realpath, set()))
+ used_font[1].add(info.num)
+
self.merge_used_characters(used_characters)
+
+ textwriter = StringIO()
+ lastfont = None
+
+ # Glyphs
+ for ox, oy, info in m.glyphs:
+ oy = m.height - oy + info.offset
+ postscript_name = info.postscript_name
+ fontsize = info.fontsize
+ symbol_name = info.symbol_name
+
+ if (postscript_name, fontsize) != lastfont:
+ ps = """/%(postscript_name)s findfont
+%(fontsize)s scalefont
+setfont
+""" % locals()
+ lastfont = postscript_name, fontsize
+ textwriter.write(ps)
+
+ ps = """%(ox)f %(oy)f moveto
+/%(symbol_name)s glyphshow\n
+""" % locals()
+ textwriter.write(ps)
+
+ # Rects
+ for x1, y1, x2, y2 in m.rects:
+ ps = "%f %f %f %f rectfill\n" % (x1, m.height - y2, x2 - x1, y2 - y1)
+ textwriter.write(ps)
+
self.set_color(*gc.get_rgb())
- thetext = pswriter.getvalue()
+ thetext = textwriter.getvalue()
ps = """gsave
%(x)f %(y)f translate
%(angle)f rotate
@@ -964,7 +998,7 @@
class NullWriter(object):
def write(self, *kl, **kwargs):
pass
-
+
self._pswriter = NullWriter()
else:
self._pswriter = StringIO()
@@ -1096,7 +1130,7 @@
class NullWriter(object):
def write(self, *kl, **kwargs):
pass
-
+
self._pswriter = NullWriter()
else:
self._pswriter = StringIO()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-20 13:59:09
|
Revision: 7275
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7275&view=rev
Author: evilguru
Date: 2009-07-20 13:59:03 +0000 (Mon, 20 Jul 2009)
Log Message:
-----------
Also remove the wx mathtex example on account of also belonging in mathtex.
Removed Paths:
-------------
branches/mathtex/examples/user_interfaces/mathtext_wx.py
Deleted: branches/mathtex/examples/user_interfaces/mathtext_wx.py
===================================================================
--- branches/mathtex/examples/user_interfaces/mathtext_wx.py 2009-07-20 13:53:21 UTC (rev 7274)
+++ branches/mathtex/examples/user_interfaces/mathtext_wx.py 2009-07-20 13:59:03 UTC (rev 7275)
@@ -1,124 +0,0 @@
-"""
-Demonstrates how to convert mathtext to a wx.Bitmap for display in various
-controls on wxPython.
-"""
-
-import matplotlib
-matplotlib.use("WxAgg")
-from numpy import arange, sin, pi, cos, log
-from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
-from matplotlib.backends.backend_wx import NavigationToolbar2Wx
-from matplotlib.figure import Figure
-
-import wx
-
-IS_GTK = 'wxGTK' in wx.PlatformInfo
-IS_WIN = 'wxMSW' in wx.PlatformInfo
-IS_MAC = 'wxMac' in wx.PlatformInfo
-
-############################################################
-# This is where the "magic" happens.
-from matplotlib.mathtext import MathTextParser
-mathtext_parser = MathTextParser("Bitmap")
-def mathtext_to_wxbitmap(s):
- ftimage, depth = mathtext_parser.parse(s, 150)
- return wx.BitmapFromBufferRGBA(
- ftimage.get_width(), ftimage.get_height(),
- ftimage.as_rgba_str())
-############################################################
-
-functions = [
- (r'$\sin(2 \pi x)$' , lambda x: sin(2*pi*x)),
- (r'$\frac{4}{3}\pi x^3$' , lambda x: (4.0 / 3.0) * pi * x**3),
- (r'$\cos(2 \pi x)$' , lambda x: cos(2*pi*x)),
- (r'$\log(x)$' , lambda x: log(x))
-]
-
-class CanvasFrame(wx.Frame):
- def __init__(self, parent, title):
- wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
- self.SetBackgroundColour(wx.NamedColor("WHITE"))
-
- self.figure = Figure()
- self.axes = self.figure.add_subplot(111)
- self.change_plot(0)
-
- self.canvas = FigureCanvas(self, -1, self.figure)
-
- self.sizer = wx.BoxSizer(wx.VERTICAL)
- self.add_buttonbar()
- self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
- self.add_toolbar() # comment this out for no toolbar
-
- menuBar = wx.MenuBar()
-
- # File Menu
- menu = wx.Menu()
- menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
- menuBar.Append(menu, "&File")
-
- if IS_GTK or IS_WIN:
- # Equation Menu
- menu = wx.Menu()
- for i, (mt, func) in enumerate(functions):
- bm = mathtext_to_wxbitmap(mt)
- item = wx.MenuItem(menu, 1000 + i, "")
- item.SetBitmap(bm)
- menu.AppendItem(item)
- self.Bind(wx.EVT_MENU, self.OnChangePlot, item)
- menuBar.Append(menu, "&Functions")
-
- self.SetMenuBar(menuBar)
-
- self.SetSizer(self.sizer)
- self.Fit()
-
- def add_buttonbar(self):
- self.button_bar = wx.Panel(self)
- self.button_bar_sizer = wx.BoxSizer(wx.HORIZONTAL)
- self.sizer.Add(self.button_bar, 0, wx.LEFT | wx.TOP | wx.GROW)
-
- for i, (mt, func) in enumerate(functions):
- bm = mathtext_to_wxbitmap(mt)
- button = wx.BitmapButton(self.button_bar, 1000 + i, bm)
- self.button_bar_sizer.Add(button, 1, wx.GROW)
- self.Bind(wx.EVT_BUTTON, self.OnChangePlot, button)
-
- self.button_bar.SetSizer(self.button_bar_sizer)
-
- def add_toolbar(self):
- """Copied verbatim from embedding_wx2.py"""
- self.toolbar = NavigationToolbar2Wx(self.canvas)
- self.toolbar.Realize()
- if IS_MAC:
- self.SetToolBar(self.toolbar)
- else:
- tw, th = self.toolbar.GetSizeTuple()
- fw, fh = self.canvas.GetSizeTuple()
- self.toolbar.SetSize(wx.Size(fw, th))
- self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
- self.toolbar.update()
-
- def OnPaint(self, event):
- self.canvas.draw()
-
- def OnChangePlot(self, event):
- self.change_plot(event.GetId() - 1000)
-
- def change_plot(self, plot_number):
- t = arange(1.0,3.0,0.01)
- s = functions[plot_number][1](t)
- self.axes.clear()
- self.axes.plot(t, s)
- self.Refresh()
-
-class MyApp(wx.App):
- def OnInit(self):
- frame = CanvasFrame(None, "wxPython mathtext demo app")
- self.SetTopWindow(frame)
- frame.Show(True)
- return True
-
-app = MyApp()
-app.MainLoop()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-20 13:53:24
|
Revision: 7274
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7274&view=rev
Author: evilguru
Date: 2009-07-20 13:53:21 +0000 (Mon, 20 Jul 2009)
Log Message:
-----------
Remove a mathtex demo from matplotlib. These now live in mathtex as opposed to matplotlib.
Removed Paths:
-------------
branches/mathtex/examples/api/mathtext_asarray.py
Deleted: branches/mathtex/examples/api/mathtext_asarray.py
===================================================================
--- branches/mathtex/examples/api/mathtext_asarray.py 2009-07-19 21:33:18 UTC (rev 7273)
+++ branches/mathtex/examples/api/mathtext_asarray.py 2009-07-20 13:53:21 UTC (rev 7274)
@@ -1,24 +0,0 @@
-"""
-Load a mathtext image as numpy array
-"""
-
-import numpy as np
-import matplotlib.mathtext as mathtext
-import matplotlib.pyplot as plt
-import matplotlib
-matplotlib.rc('image', origin='upper')
-
-parser = mathtext.MathTextParser("Bitmap")
-
-
-parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100)
-
-
-rgba1, depth1 = parser.to_rgba(r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
-rgba2, depth2 = parser.to_rgba(r'some other string', color='red', fontsize=20, dpi=200)
-
-fig = plt.figure()
-fig.figimage(rgba1.astype(float)/255., 100, 100)
-fig.figimage(rgba2.astype(float)/255., 100, 300)
-
-plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-19 21:33:20
|
Revision: 7273
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7273&view=rev
Author: evilguru
Date: 2009-07-19 21:33:18 +0000 (Sun, 19 Jul 2009)
Log Message:
-----------
Port over the Cairo backend to mathtex. Just PS and OS X left.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_cairo.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_cairo.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_cairo.py 2009-07-19 13:35:15 UTC (rev 7272)
+++ branches/mathtex/lib/matplotlib/backends/backend_cairo.py 2009-07-19 21:33:18 UTC (rev 7273)
@@ -42,12 +42,14 @@
FigureManagerBase, FigureCanvasBase
from matplotlib.cbook import is_string_like
from matplotlib.figure import Figure
-from matplotlib.mathtext import MathTextParser
from matplotlib.path import Path
from matplotlib.transforms import Bbox, Affine2D
from matplotlib.font_manager import ttfFontProperty
from matplotlib import rcParams
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_cairo import MathtexBackendCairo
+
_debug = False
#_debug = True
@@ -94,7 +96,6 @@
self.gc = GraphicsContextCairo (renderer=self)
self.text_ctx = cairo.Context (
cairo.ImageSurface (cairo.FORMAT_ARGB32,1,1))
- self.mathtext_parser = MathTextParser('Cairo')
def set_ctx_from_surface (self, surface):
self.gc.ctx = cairo.Context (surface)
@@ -203,35 +204,18 @@
if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
ctx = gc.ctx
- width, height, descent, glyphs, rects = self.mathtext_parser.parse(
- s, self.dpi, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), self.dpi)
+ b = MathtexBackendCairo()
+ m.render_to_backend(b)
+
ctx.save()
- ctx.translate(x, y)
+ ctx.translate(x, y - m.height - m.depth)
if angle:
ctx.rotate (-angle * npy.pi / 180)
- for font, fontsize, s, ox, oy in glyphs:
- ctx.new_path()
- ctx.move_to(ox, oy)
+ b.render_to_context(ctx)
- fontProp = ttfFontProperty(font)
- ctx.save()
- ctx.select_font_face (fontProp.name,
- self.fontangles [fontProp.style],
- self.fontweights[fontProp.weight])
-
- size = fontsize * self.dpi / 72.0
- ctx.set_font_size(size)
- ctx.show_text(s.encode("utf-8"))
- ctx.restore()
-
- for ox, oy, w, h in rects:
- ctx.new_path()
- ctx.rectangle (ox, oy, w, h)
- ctx.set_source_rgb (0, 0, 0)
- ctx.fill_preserve()
-
ctx.restore()
@@ -250,9 +234,8 @@
def get_text_width_height_descent(self, s, prop, ismath):
if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
if ismath:
- width, height, descent, fonts, used_characters = self.mathtext_parser.parse(
- s, self.dpi, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), self.dpi)
+ return m.width, m.height, m.depth
ctx = self.text_ctx
ctx.save()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-07-19 13:35:17
|
Revision: 7272
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7272&view=rev
Author: jdh2358
Date: 2009-07-19 13:35:15 +0000 (Sun, 19 Jul 2009)
Log Message:
-----------
fixed Axes.step docstring per sf bug 2823304
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-19 10:15:57 UTC (rev 7271)
+++ trunk/matplotlib/CHANGELOG 2009-07-19 13:35:15 UTC (rev 7272)
@@ -1,3 +1,8 @@
+2009-07-19 Fixed the docstring of Axes.step to reflect the correct
+ meaning of the kwargs "pre" and "post" - See SF bug
+ https://sourceforge.net/tracker/index.php?func=detail&aid=2823304&group_id=80706&atid=560720
+ - JDH
+
2009-07-18 Fix support for hatches without color fills to pdf and svg
backends. Add an example of that to hatch_demo.py. - JKS
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-07-19 10:15:57 UTC (rev 7271)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-07-19 13:35:15 UTC (rev 7272)
@@ -4109,9 +4109,9 @@
Keyword arguments:
*where*: [ 'pre' | 'post' | 'mid' ]
- If 'pre', the interval from x[i] to x[i+1] has level y[i]
+ If 'pre', the interval from x[i] to x[i+1] has level y[i+1]
- If 'post', that interval has level y[i+1]
+ If 'post', that interval has level y[i]
If 'mid', the jumps in *y* occur half-way between the
*x*-values.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-19 10:16:01
|
Revision: 7271
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7271&view=rev
Author: evilguru
Date: 2009-07-19 10:15:57 +0000 (Sun, 19 Jul 2009)
Log Message:
-----------
Port the SVG backend over to mathtex.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_svg.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_svg.py 2009-07-18 08:35:56 UTC (rev 7270)
+++ branches/mathtex/lib/matplotlib/backends/backend_svg.py 2009-07-19 10:15:57 UTC (rev 7271)
@@ -16,11 +16,12 @@
from matplotlib.figure import Figure
from matplotlib.font_manager import findfont, FontProperties
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
-from matplotlib.mathtext import MathTextParser
from matplotlib.path import Path
from matplotlib.transforms import Affine2D
from matplotlib import _png
+from mathtex.mathtex_main import Mathtex
+
from xml.sax.saxutils import escape as escape_xml_text
backend_version = __version__
@@ -54,7 +55,6 @@
self._path_collection_id = 0
self._imaged = {}
self._hatchd = {}
- self.mathtext_parser = MathTextParser('SVG')
svgwriter.write(svgProlog%(width,height,width,height))
def _draw_svg_element(self, element, details, gc, rgbFace):
@@ -485,12 +485,17 @@
def _draw_mathtext(self, gc, x, y, s, prop, angle):
"""
- Draw math text using matplotlib.mathtext
+ Draw math text using mathtex
"""
- width, height, descent, svg_elements, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
- svg_glyphs = svg_elements.svg_glyphs
- svg_rects = svg_elements.svg_rects
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), 72.0)
+
+ # Extract the glyphs and rects to render
+ svg_glyphs = [(info.font, info.fontsize, unichr(info.num),
+ ox, m.height - oy + info.offset, info.metrics)
+ for ox, oy, info in m.glyphs]
+ svg_rects = [(x1, m.height - y1 + 1, x2 - x1, y2 - y1)
+ for x1, y1, x2, y2 in m.rects]
+
color = rgb2hex(gc.get_rgb()[:3])
write = self._svgwriter.write
@@ -587,9 +592,9 @@
def get_text_width_height_descent(self, s, prop, ismath):
if ismath:
- width, height, descent, trash, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), 72.0)
+ return m.width, m.height, m.depth
font = self._get_font(prop)
font.set_text(s, 0.0, flags=LOAD_NO_HINTING)
w, h = font.get_width_height()
@@ -639,7 +644,7 @@
# the problem. I hope someone who knows the svg backends
# take a look at this problem. Meanwhile, the dpi
# parameter is ignored and image_dpi is fixed at 72. - JJL
-
+
#image_dpi = kwargs.pop("dpi", 72)
image_dpi = 72
_bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-07-18 08:36:04
|
Revision: 7270
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7270&view=rev
Author: jouni
Date: 2009-07-18 08:35:56 +0000 (Sat, 18 Jul 2009)
Log Message:
-----------
Fix support for hatches without color fills to pdf and svg backends.
Add an example of that to hatch_demo.py.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/hatch_demo.py
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-17 20:03:21 UTC (rev 7269)
+++ trunk/matplotlib/CHANGELOG 2009-07-18 08:35:56 UTC (rev 7270)
@@ -1,3 +1,6 @@
+2009-07-18 Fix support for hatches without color fills to pdf and svg
+ backends. Add an example of that to hatch_demo.py. - JKS
+
2009-07-17 Removed fossils from swig version of agg backend. - EF
2009-07-14 initial submission of the annotation guide. -JJL
Modified: trunk/matplotlib/examples/pylab_examples/hatch_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hatch_demo.py 2009-07-17 20:03:21 UTC (rev 7269)
+++ trunk/matplotlib/examples/pylab_examples/hatch_demo.py 2009-07-18 08:35:56 UTC (rev 7270)
@@ -3,18 +3,29 @@
PDF, SVG and Agg backends only.
"""
import matplotlib.pyplot as plt
+from matplotlib.patches import Ellipse, Polygon
fig = plt.figure()
-ax1 = fig.add_subplot(121)
+ax1 = fig.add_subplot(131)
ax1.bar(range(1,5), range(1,5), color='red', edgecolor='black', hatch="/")
ax1.bar(range(1,5), [6] * 4, bottom=range(1,5), color='blue', edgecolor='black', hatch='//')
+ax1.set_xticks([1.5,2.5,3.5,4.5])
-ax2 = fig.add_subplot(122)
+ax2 = fig.add_subplot(132)
bars = ax2.bar(range(1,5), range(1,5), color='yellow', ecolor='black') + \
ax2.bar(range(1, 5), [6] * 4, bottom=range(1,5), color='green', ecolor='black')
+ax2.set_xticks([1.5,2.5,3.5,4.5])
patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.')
for bar, pattern in zip(bars, patterns):
bar.set_hatch(pattern)
+ax3 = fig.add_subplot(133)
+ax3.fill([1,3,3,1],[1,1,2,2], fill=False, hatch='\\')
+ax3.add_patch(Ellipse((4,1.5), 4, 0.5, fill=False, hatch='*'))
+ax3.add_patch(Polygon([[0,0],[4,1.1],[6,2.5],[2,1.4]], closed=True,
+ fill=False, hatch='/'))
+ax3.set_xlim((0,6))
+ax3.set_ylim((0,2.5))
+
plt.show()
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-07-17 20:03:21 UTC (rev 7269)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-07-18 08:35:56 UTC (rev 7270)
@@ -1715,14 +1715,27 @@
return `d`
def _strokep(self):
+ """
+ Predicate: does the path need to be stroked (its outline drawn)?
+ This tests for the various conditions that disable stroking
+ the path, in which case it would presumably be filled.
+ """
return (self._linewidth > 0 and self._alpha > 0 and
(len(self._rgb) <= 3 or self._rgb[3] != 0.0))
def _fillp(self):
- return ((self._fillcolor is not None or self._hatch) and
- (len(self._fillcolor) <= 3 or self._fillcolor[3] != 0.0))
+ """
+ Predicate: does the path need to be filled?
+ """
+ return self._hatch or \
+ (self._fillcolor is not None and
+ (len(self._fillcolor) <= 3 or self._fillcolor[3] != 0.0))
def close_and_paint(self):
+ """
+ Return the appropriate pdf operator to close the path and
+ cause it to be stroked, filled, or both.
+ """
if self._strokep():
if self._fillp():
return Op.close_fill_stroke
@@ -1735,6 +1748,10 @@
return Op.endpath
def paint(self):
+ """
+ Return the appropriate pdf operator to cause the path to be
+ stroked, filled, or both.
+ """
if self._strokep():
if self._fillp():
return Op.fill_stroke
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2009-07-17 20:03:21 UTC (rev 7269)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2009-07-18 08:35:56 UTC (rev 7270)
@@ -102,9 +102,13 @@
path_data = self._convert_path(
gc.get_hatch_path(),
Affine2D().scale(HATCH_SIZE).scale(1.0, -1.0).translate(0, HATCH_SIZE))
+ if rgbFace is None:
+ fill = 'none'
+ else:
+ fill = rgb2hex(rgbFace)
self._svgwriter.write(
'<rect x="0" y="0" width="%d" height="%d" fill="%s"/>' %
- (HATCH_SIZE+1, HATCH_SIZE+1, rgb2hex(rgbFace)))
+ (HATCH_SIZE+1, HATCH_SIZE+1, fill))
path = '<path d="%s" fill="%s" stroke="%s" stroke-width="1.0"/>' % (
path_data, rgb2hex(gc.get_rgb()[:3]), rgb2hex(gc.get_rgb()[:3]))
self._svgwriter.write(path)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-17 20:03:22
|
Revision: 7269
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7269&view=rev
Author: evilguru
Date: 2009-07-17 20:03:21 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
Add the PDF backend to the mathtex family. Resistance is futile.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_pdf.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_pdf.py 2009-07-17 19:03:07 UTC (rev 7268)
+++ branches/mathtex/lib/matplotlib/backends/backend_pdf.py 2009-07-17 20:03:21 UTC (rev 7269)
@@ -38,11 +38,12 @@
import matplotlib.dviread as dviread
from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \
LOAD_NO_HINTING, KERNING_UNFITTED
-from matplotlib.mathtext import MathTextParser
from matplotlib.transforms import Affine2D, Bbox, BboxBase, TransformedPath
from matplotlib.path import Path
from matplotlib import ttconv
+from mathtex.mathtex_main import Mathtex
+
# Overview
#
# The low-level knowledge about pdf syntax lies mainly in the pdfRepr
@@ -1242,7 +1243,6 @@
RendererBase.__init__(self)
self.file = file
self.gc = self.new_gc()
- self.mathtext_parser = MathTextParser("Pdf")
self.image_dpi = image_dpi
self.tex_font_map = None
@@ -1344,10 +1344,23 @@
def draw_mathtext(self, gc, x, y, s, prop, angle):
# TODO: fix positioning and encoding
- width, height, descent, glyphs, rects, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), 72.0)
+
+ # Generate the dict of used characters
+ used_characters = {}
+ for ox, oy, info in m.glyphs:
+ realpath, stat_key = get_realpath_and_stat(info.font.fname)
+ used_font = used_characters.setdefault(stat_key, (realpath, set()))
+ used_font[1].add(info.num)
+
self.merge_used_characters(used_characters)
+ # Extract the glyphs and rects to render
+ glyphs = [(ox, m.height - oy + info.offset, info.font.fname,
+ info.fontsize, info.num, info.symbol_name)
+ for ox, oy, info in m.glyphs]
+ rects = [(x1, m.height - y2, x2 - x1, y2 - y1) for x1, y1, x2, y2 in m.rects]
+
# When using Type 3 fonts, we can't use character codes higher
# than 255, so we use the "Do" command to render those
# instead.
@@ -1641,8 +1654,9 @@
return w, h, d
if ismath:
- w, h, d, glyphs, rects, used_characters = \
- self.mathtext_parser.parse(s, 72, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), 72.0)
+ w, h, d = m.width, m.height, m.depth
elif rcParams['pdf.use14corefonts']:
font = self._get_font_afm(prop)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2009-07-17 19:03:22
|
Revision: 7268
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7268&view=rev
Author: efiring
Date: 2009-07-17 19:03:07 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
Remove swig fossils remaining from old version of agg wrapper
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/src/_backend_agg.cpp
Removed Paths:
-------------
trunk/matplotlib/src/agg.cxx
trunk/matplotlib/src/swig_runtime.h
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-17 18:44:30 UTC (rev 7267)
+++ trunk/matplotlib/CHANGELOG 2009-07-17 19:03:07 UTC (rev 7268)
@@ -1,3 +1,5 @@
+2009-07-17 Removed fossils from swig version of agg backend. - EF
+
2009-07-14 initial submission of the annotation guide. -JJL
2009-07-14 axes_grid : minor improvements in anchored_artists and
@@ -3,5 +5,5 @@
inset_locator. -JJL
-2009-07-14 Fix a few bugs in ConnectionStyle algorithms. Add
+2009-07-14 Fix a few bugs in ConnectionStyle algorithms. Add
ConnectionPatch class. -JJL
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2009-07-17 18:44:30 UTC (rev 7267)
+++ trunk/matplotlib/src/_backend_agg.cpp 2009-07-17 19:03:07 UTC (rev 7268)
@@ -34,7 +34,6 @@
#include "agg_conv_shorten_path.h"
#include "util/agg_color_conv_rgb8.h"
-#include "swig_runtime.h"
#include "MPL_isnan.h"
#include "numpy/arrayobject.h"
Deleted: trunk/matplotlib/src/agg.cxx
===================================================================
--- trunk/matplotlib/src/agg.cxx 2009-07-17 18:44:30 UTC (rev 7267)
+++ trunk/matplotlib/src/agg.cxx 2009-07-17 19:03:07 UTC (rev 7268)
@@ -1,31983 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.31
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPYTHON
-#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
-
-#ifdef __cplusplus
-template<class T> class SwigValueWrapper {
- T *tt;
-public:
- SwigValueWrapper() : tt(0) { }
- SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
- SwigValueWrapper(const T& t) : tt(new T(t)) { }
- ~SwigValueWrapper() { delete tt; }
- SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
- operator T&() const { return *tt; }
- T *operator&() { return tt; }
-private:
- SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
-};
-#endif
-
-/* -----------------------------------------------------------------------------
- * This section contains generic SWIG labels for method/variable
- * declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
-
-/* template workaround for compilers that cannot correctly implement the C++ standard */
-#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC)
-# if (__SUNPRO_CC <= 0x560)
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# else
-# define SWIGTEMPLATEDISAMBIGUATOR
-# endif
-# else
-# define SWIGTEMPLATEDISAMBIGUATOR
-# endif
-#endif
-
-/* inline attribute */
-#ifndef SWIGINLINE
-# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-# define SWIGINLINE inline
-# else
-# define SWIGINLINE
-# endif
-#endif
-
-/* attribute recognised by some compilers to avoid 'unused' warnings */
-#ifndef SWIGUNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-# elif defined(__ICC)
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-#endif
-
-#ifndef SWIGUNUSEDPARM
-# ifdef __cplusplus
-# define SWIGUNUSEDPARM(p)
-# else
-# define SWIGUNUSEDPARM(p) p SWIGUNUSED
-# endif
-#endif
-
-/* internal SWIG method */
-#ifndef SWIGINTERN
-# define SWIGINTERN static SWIGUNUSED
-#endif
-
-/* internal inline SWIG method */
-#ifndef SWIGINTERNINLINE
-# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
-#endif
-
-/* exporting methods */
-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# ifndef GCC_HASCLASSVISIBILITY
-# define GCC_HASCLASSVISIBILITY
-# endif
-#endif
-
-#ifndef SWIGEXPORT
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(STATIC_LINKED)
-# define SWIGEXPORT
-# else
-# define SWIGEXPORT __declspec(dllexport)
-# endif
-# else
-# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
-# define SWIGEXPORT __attribute__ ((visibility("default")))
-# else
-# define SWIGEXPORT
-# endif
-# endif
-#endif
-
-/* calling conventions for Windows */
-#ifndef SWIGSTDCALL
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# define SWIGSTDCALL __stdcall
-# else
-# define SWIGSTDCALL
-# endif
-#endif
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-
-/* Python.h has to appear first */
-#include <Python.h>
-
-/* -----------------------------------------------------------------------------
- * swigrun.swg
- *
- * This file contains generic CAPI SWIG runtime support for pointer
- * type checking.
- * ----------------------------------------------------------------------------- */
-
-/* This should only be incremented when either the layout of swig_type_info changes,
- or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
-
-/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
-#ifdef SWIG_TYPE_TABLE
-# define SWIG_QUOTE_STRING(x) #x
-# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
-# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
-#else
-# define SWIG_TYPE_TABLE_NAME
-#endif
-
-/*
- You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
- creating a static or dynamic library from the swig runtime code.
- In 99.9% of the cases, swig just needs to declare them as 'static'.
-
- But only do this if is strictly necessary, ie, if you have problems
- with your compiler or so.
-*/
-
-#ifndef SWIGRUNTIME
-# define SWIGRUNTIME SWIGINTERN
-#endif
-
-#ifndef SWIGRUNTIMEINLINE
-# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
-#endif
-
-/* Generic buffer size */
-#ifndef SWIG_BUFFER_SIZE
-# define SWIG_BUFFER_SIZE 1024
-#endif
-
-/* Flags for pointer conversions */
-#define SWIG_POINTER_DISOWN 0x1
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_OWN 0x1
-
-
-/*
- Flags/methods for returning states.
-
- The swig conversion methods, as ConvertPtr, return and integer
- that tells if the conversion was successful or not. And if not,
- an error code can be returned (see swigerrors.swg for the codes).
-
- Use the following macros/flags to set or process the returning
- states.
-
- In old swig versions, you usually write code as:
-
- if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
- // success code
- } else {
- //fail code
- }
-
- Now you can be more explicit as:
-
- int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- } else {
- // fail code
- }
-
- that seems to be the same, but now you can also do
-
- Type *ptr;
- int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- if (SWIG_IsNewObj(res) {
- ...
- delete *ptr;
- } else {
- ...
- }
- } else {
- // fail code
- }
-
- I.e., now SWIG_ConvertPtr can return new objects and you can
- identify the case and take care of the deallocation. Of course that
- requires also to SWIG_ConvertPtr to return new result values, as
-
- int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
- *ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
- }
-
- Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
- more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
- swig errors code.
-
- Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
- allows to return the 'cast rank', for example, if you have this
-
- int food(double)
- int fooi(int);
-
- and you call
-
- food(1) // cast rank '1' (1 -> 1.0)
- fooi(1) // cast rank '0'
-
- just use the SWIG_AddCast()/SWIG_CheckState()
-
-
- */
-#define SWIG_OK (0)
-#define SWIG_ERROR (-1)
-#define SWIG_IsOK(r) (r >= 0)
-#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
-
-/* The CastRankLimit says how many bits are used for the cast rank */
-#define SWIG_CASTRANKLIMIT (1 << 8)
-/* The NewMask denotes the object was created (using new/malloc) */
-#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
-#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
-/* Simple returning values */
-#define SWIG_BADOBJ (SWIG_ERROR)
-#define SWIG_OLDOBJ (SWIG_OK)
-#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
-#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
-/* Check, add and del mask methods */
-#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
-#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
-#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
-#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
-#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
-#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
-
-/* Cast-Rank Mode */
-#if defined(SWIG_CASTRANK_MODE)
-# ifndef SWIG_TypeRank
-# define SWIG_TypeRank unsigned long
-# endif
-# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
-# define SWIG_MAXCASTRANK (2)
-# endif
-# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
-# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
- return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
-}
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
- return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
-}
-#else /* no cast-rank mode */
-# define SWIG_AddCast
-# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
-#endif
-
-
-
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-
-/* Structure to store inforomation on one type */
-typedef struct swig_type_info {
- const char *name; /* mangled name of this type */
- const char *str; /* human readable name of this type */
- swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
- struct swig_cast_info *cast; /* linked list of types that can cast into this type */
- void *clientdata; /* language specific type data */
- int owndata; /* flag if the structure owns the clientdata */
-} swig_type_info;
-
-/* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
- swig_type_info *type; /* pointer to type that is equivalent to this type */
- swig_converter_func converter; /* function to cast the void pointers */
- struct swig_cast_info *next; /* pointer to next cast in linked list */
- struct swig_cast_info *prev; /* pointer to the previous cast */
-} swig_cast_info;
-
-/* Structure used to store module information
- * Each module generates one structure like this, and the runtime collects
- * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
- swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
- size_t size; /* Number of types in this module */
- struct swig_module_info *next; /* Pointer to next element in circularly linked list */
- swig_type_info **type_initial; /* Array of initially generated type structures */
- swig_cast_info **cast_initial; /* Array of initially generated casting structures */
- void *clientdata; /* Language specific module data */
-} swig_module_info;
-
-/*
- Compare two type names skipping the space characters, therefore
- "char*" == "char *" and "Class<int>" == "Class<int >", etc.
-
- Return 0 when the two name types are equivalent, as in
- strncmp, but skipping ' '.
-*/
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
- for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
- while ((*f1 == ' ') && (f1 != l1)) ++f1;
- while ((*f2 == ' ') && (f2 != l2)) ++f2;
- if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
- }
- return (l1 - f1) - (l2 - f2);
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if not equal, 1 if equal
-*/
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if equal, -1 if nb < tb, 1 if nb > tb
-*/
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty) \
- if (ty) { \
- swig_cast_info *iter = ty->cast; \
- while (iter) { \
- if (comparison) { \
- if (iter == ty->cast) return iter; \
- /* Move iter to the top of the linked list */ \
- iter->prev->next = iter->next; \
- if (iter->next) \
- iter->next->prev = iter->prev; \
- iter->next = ty->cast; \
- iter->prev = 0; \
- if (ty->cast) ty->cast->prev = iter; \
- ty->cast = iter; \
- return iter; \
- } \
- iter = iter->next; \
- } \
- } \
- return 0
-
-/*
- Check the typename
-*/
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
-
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
- SWIG_TypeCheck_Template(iter->type == from, into);
-}
-
-/*
- Cast a pointer up an inheritance hierarchy
-*/
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
-}
-
-/*
- Dynamic pointer casting. Down an inheritance hierarchy
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
- swig_type_info *lastty = ty;
- if (!ty || !ty->dcast) return ty;
- while (ty && (ty->dcast)) {
- ty = (*ty->dcast)(ptr);
- if (ty) lastty = ty;
- }
- return lastty;
-}
-
-/*
- Return the name associated with this type
-*/
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
- return ty->name;
-}
-
-/*
- Return the pretty name associated with this type,
- that is an unmangled type name in a form presentable to the user.
-*/
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
- /* The "str" field contains the equivalent pretty names of the
- type, separated by vertical-bar characters. We choose
- to print the last name, as it is often (?) the most
- specific. */
- if (!type) return NULL;
- if (type->str != NULL) {
- const char *last_name = type->str;
- const char *s;
- for (s = type->str; *s; s++)
- if (*s == '|') last_name = s+1;
- return last_name;
- }
- else
- return type->name;
-}
-
-/*
- Set the clientdata field for a type
-*/
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_cast_info *cast = ti->cast;
- /* if (ti->clientdata == clientdata) return; */
- ti->clientdata = clientdata;
-
- while (cast) {
- if (!cast->converter) {
- swig_type_info *tc = cast->type;
- if (!tc->clientdata) {
- SWIG_TypeClientData(tc, clientdata);
- }
- }
- cast = cast->next;
- }
-}
-SWIGRUNTIME void
-SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
- SWIG_TypeClientData(ti, clientdata);
- ti->owndata = 1;
-}
-
-/*
- Search for a swig_type_info structure only by mangled name
- Search is a O(log #types)
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- swig_module_info *iter = start;
- do {
- if (iter->size) {
- register size_t l = 0;
- register size_t r = iter->size - 1;
- do {
- /* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
- const char *iname = iter->types[i]->name;
- if (iname) {
- register int compare = strcmp(name, iname);
- if (compare == 0) {
- return iter->types[i];
- } else if (compare < 0) {
- if (i) {
- r = i - 1;
- } else {
- break;
- }
- } else if (compare > 0) {
- l = i + 1;
- }
- } else {
- break; /* should never happen */
- }
- } while (l <= r);
- }
- iter = iter->next;
- } while (iter != end);
- return 0;
-}
-
-/*
- Search for a swig_type_info structure for either a mangled name or a human readable name.
- It first searches the mangled names of the types, which is a O(log #types)
- If a type is not found it then searches the human readable names, which is O(#types).
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- /* STEP 1: Search the name field using binary search */
- swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
- if (ret) {
- return ret;
- } else {
- /* STEP 2: If the type hasn't been found, do a complete search
- of the str field (the human readable name) */
- swig_module_info *iter = start;
- do {
- register size_t i = 0;
- for (; i < iter->size; ++i) {
- if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
- return iter->types[i];
- }
- iter = iter->next;
- } while (iter != end);
- }
-
- /* neither found a match */
- return 0;
-}
-
-/*
- Pack binary data into a string
-*/
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
- static const char hex[17] = "0123456789abcdef";
- register const unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register unsigned char uu = *u;
- *(c++) = hex[(uu & 0xf0) >> 4];
- *(c++) = hex[uu & 0xf];
- }
- return c;
-}
-
-/*
- Unpack binary data from a string
-*/
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
- register unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register char d = *(c++);
- register unsigned char uu;
- if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
- else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
- else
- return (char *) 0;
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
- else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
- else
- return (char *) 0;
- *u = uu;
- }
- return c;
-}
-
-/*
- Pack 'void *' into a string buffer.
-*/
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
- char *r = buff;
- if ((2*sizeof(void *) + 2) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,&ptr,sizeof(void *));
- if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
- strcpy(r,name);
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- *ptr = (void *) 0;
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
-
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
- char *r = buff;
- size_t lname = (name ? strlen(name) : 0);
- if ((2*sz + 2 + lname) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,ptr,sz);
- if (lname) {
- strncpy(r,name,lname+1);
- } else {
- *r = 0;
- }
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- memset(ptr,0,sz);
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sz);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Errors in SWIG */
-#define SWIG_UnknownError -1
-#define SWIG_IOError -2
-#define SWIG_RuntimeError -3
-#define SWIG_IndexError -4
-#define SWIG_TypeError -5
-#define SWIG_DivisionByZero -6
-#define SWIG_OverflowError -7
-#define SWIG_SyntaxError -8
-#define SWIG_ValueError -9
-#define SWIG_SystemError -10
-#define SWIG_AttributeError -11
-#define SWIG_MemoryError -12
-#define SWIG_NullReferenceError -13
-
-
-
-
-/* Add PyOS_snprintf for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
-# define PyOS_snprintf _snprintf
-# else
-# define PyOS_snprintf snprintf
-# endif
-#endif
-
-/* A crude PyString_FromFormat implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-
-#ifndef SWIG_PYBUFFER_SIZE
-# define SWIG_PYBUFFER_SIZE 1024
-#endif
-
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
- va_list ap;
- char buf[SWIG_PYBUFFER_SIZE * 2];
- int res;
- va_start(ap, fmt);
- res = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
-#endif
-
-/* Add PyObject_Del for old Pythons */
-#if PY_VERSION_HEX < 0x01060000
-# define PyObject_Del(op) PyMem_DEL((op))
-#endif
-#ifndef PyObject_DEL
-# define PyObject_DEL PyObject_Del
-#endif
-
-/* A crude PyExc_StopIteration exception for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# ifndef PyExc_StopIteration
-# define PyExc_StopIteration PyExc_RuntimeError
-# endif
-# ifndef PyObject_GenericGetAttr
-# define PyObject_GenericGetAttr 0
-# endif
-#endif
-/* Py_NotImplemented is defined in 2.1 and up. */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef Py_NotImplemented
-# define Py_NotImplemented PyExc_RuntimeError
-# endif
-#endif
-
-
-/* A crude PyString_AsStringAndSize implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef PyString_AsStringAndSize
-# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
-# endif
-#endif
-
-/* PySequence_Size for old Pythons */
-#if PY_VERSION_HEX < 0x02000000
-# ifndef PySequence_Size
-# define PySequence_Size PySequence_Length
-# endif
-#endif
-
-
-/* PyBool_FromLong for old Pythons */
-#if PY_VERSION_HEX < 0x02030000
-static
-PyObject *PyBool_FromLong(long ok)
-{
- PyObject *result = ok ? Py_True : Py_False;
- Py_INCREF(result);
- return result;
-}
-#endif
-
-/* Py_ssize_t for old Pythons */
-/* This code is as recommended by: */
-/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-/* -----------------------------------------------------------------------------
- * error manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME PyObject*
-SWIG_Python_ErrorType(int code) {
- PyObject* type = 0;
- switch(code) {
- case SWIG_MemoryError:
- type = PyExc_MemoryError;
- break;
- case SWIG_IOError:
- type = PyExc_IOError;
- break;
- case SWIG_RuntimeError:
- type = PyExc_RuntimeError;
- break;
- case SWIG_IndexError:
- type = PyExc_IndexError;
- break;
- case SWIG_TypeError:
- type = PyExc_TypeError;
- break;
- case SWIG_DivisionByZero:
- type = PyExc_ZeroDivisionError;
- break;
- case SWIG_OverflowError:
- type = PyExc_OverflowError;
- break;
- case SWIG_SyntaxError:
- type = PyExc_SyntaxError;
- break;
- case SWIG_ValueError:
- type = PyExc_ValueError;
- break;
- case SWIG_SystemError:
- type = PyExc_SystemError;
- break;
- case SWIG_AttributeError:
- type = PyExc_AttributeError;
- break;
- default:
- type = PyExc_RuntimeError;
- }
- return type;
-}
-
-
-SWIGRUNTIME void
-SWIG_Python_AddErrorMsg(const char* mesg)
-{
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
-
- if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- PyErr_Clear();
- Py_XINCREF(type);
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- Py_DECREF(old_str);
- Py_DECREF(value);
- } else {
- PyErr_Format(PyExc_RuntimeError, mesg);
- }
-}
-
-
-
-#if defined(SWIG_PYTHON_NO_THREADS)
-# if defined(SWIG_PYTHON_THREADS)
-# undef SWIG_PYTHON_THREADS
-# endif
-#endif
-#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
-# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
-# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
-# define SWIG_PYTHON_USE_GIL
-# endif
-# endif
-# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-# ifndef SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
-# endif
-# ifdef __cplusplus /* C++ code */
- class SWIG_Python_Thread_Block {
- bool status;
- PyGILState_STATE state;
- public:
- void end() { if (status) { PyGILState_Release(state); status = false;} }
- SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
- ~SWIG_Python_Thread_Block() { end(); }
- };
- class SWIG_Python_Thread_Allow {
- bool status;
- PyThreadState *save;
- public:
- void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
- SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
- ~SWIG_Python_Thread_Allow() { end(); }
- };
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
-# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
-# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
-# else /* C code */
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
-# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
-# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
-# endif
-# else /* Old thread way, not implemented, user must provide it */
-# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
-# define SWIG_PYTHON_THREAD_END_ALLOW
-# endif
-# endif
-#else /* No thread support */
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# define SWIG_PYTHON_THREAD_END_ALLOW
-#endif
-
-/* -----------------------------------------------------------------------------
- * Python API portion that goes into the runtime
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* -----------------------------------------------------------------------------
- * Constant declarations
- * ----------------------------------------------------------------------------- */
-
-/* Constant Types */
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY 5
-
-/* Constant information structure */
-typedef struct swig_const_info {
- int type;
- char *name;
- long lvalue;
- double dvalue;
- void *pvalue;
- swig_type_info **ptype;
-} swig_const_info;
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-/* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
- * pyrun.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * ----------------------------------------------------------------------------- */
-
-/* Common SWIG API */
-
-/* for raw pointers */
-#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
-#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
-#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
-#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
-#define swig_owntype int
-
-/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-/* for class or struct pointers */
-#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-
-/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
-
-/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-
-/* Runtime API */
-
-#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
-
-#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
-#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
-#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
-#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
-#define SWIG_fail goto fail
-
-
-/* Runtime API implementation */
-
-/* Error manipulation */
-
-SWIGINTERN void
-SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetObject(errtype, obj);
- Py_DECREF(obj);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-SWIGINTERN void
-SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetString(errtype, (char *) msg);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-
-/* Set a constant value */
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
- PyDict_SetItemString(d, (char*) name, obj);
- Py_DECREF(obj);
-}
-
-/* Append a value to the result obj */
-
-SWIGINTERN PyObject*
-SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyList_Check(result)) {
- PyObject *o2 = result;
- result = PyList_New(1);
- PyList_SetItem(result, 0, o2);
- }
- PyList_Append(result,obj);
- Py_DECREF(obj);
- }
- return result;
-#else
- PyObject* o2;
- PyObject* o3;
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyTuple_Check(result)) {
- o2 = result;
- result = PyTuple_New(1);
- PyTuple_SET_ITEM(result, 0, o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SET_ITEM(o3, 0, obj);
- o2 = result;
- result = PySequence_Concat(o2, o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
- }
- return result;
-#endif
-}
-
-/* Unpack the argument tuple */
-
-SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
-{
- if (!args) {
- if (!min && !max) {
- return 1;
- } else {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
- name, (min == max ? "" : "at least "), min);
- return 0;
- }
- }
- if (!PyTuple_Check(args)) {
- PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
- return 0;
- } else {
- register int l = PyTuple_GET_SIZE(args);
- if (l < min) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at least "), min, l);
- return 0;
- } else if (l > max) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at most "), max, l);
- return 0;
- } else {
- register int i;
- for (i = 0; i < l; ++i) {
- objs[i] = PyTuple_GET_ITEM(args, i);
- }
- for (; l < max; ++l) {
- objs[l] = 0;
- }
- return i + 1;
- }
- }
-}
-
-/* A functor is a function object with one single object argument */
-#if PY_VERSION_HEX >= 0x02020000
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
-#else
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
-#endif
-
-/*
- Helper for static pointer initialization for both C and C++ code, for example
- static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
-*/
-#ifdef __cplusplus
-#define SWIG_STATIC_POINTER(var) var
-#else
-#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
-#endif
-
-/* -----------------------------------------------------------------------------
- * Pointer declarations
- * ----------------------------------------------------------------------------- */
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
-#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
-
-#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* How to access Py_None */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef SWIG_PYTHON_NO_BUILD_NONE
-# ifndef SWIG_PYTHON_BUILD_NONE
-# define SWIG_PYTHON_BUILD_NONE
-# endif
-# endif
-#endif
-
-#ifdef SWIG_PYTHON_BUILD_NONE
-# ifdef Py_None
-# undef Py_None
-# define Py_None SWIG_Py_None()
-# endif
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_Py_None(void)
-{
- PyObject *none = Py_BuildValue((char*)"");
- Py_DECREF(none);
- return none;
-}
-SWIGRUNTIME PyObject *
-SWIG_Py_None(void)
-{
- static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
- return none;
-}
-#endif
-
-/* The python void return value */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Py_Void(void)
-{
- PyObject *none = Py_None;
- Py_INCREF(none);
- return none;
-}
-
-/* PySwigClientData */
-
-typedef struct {
- PyObject *klass;
- PyObject *newraw;
- PyObject *newargs;
- PyObject *destroy;
- int delargs;
- int implicitconv;
-} PySwigClientData;
-
-SWIGRUNTIMEINLINE int
-SWIG_Python_CheckImplicit(swig_type_info *ty)
-{
- PySwigClientData *data = (PySwigClientData *)ty->clientdata;
- return data ? data->implicitconv : 0;
-}
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_ExceptionType(swig_type_info *desc) {
- PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
- PyObject *klass = data ? data->klass : 0;
- return (klass ? klass : PyExc_RuntimeError);
-}
-
-
-SWIGRUNTIME PySwigClientData *
-PySwigClientData_New(PyObject* obj)
-{
- if (!obj) {
- return 0;
- } else {
- PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
- /* the klass element */
- data->klass = obj;
- Py_INCREF(data->klass);
- /* the newraw method and newargs arguments used to create a new raw instance */
- if (PyClass_Check(obj)) {
- data->newraw = 0;
- data->newargs = obj;
- Py_INCREF(obj);
- } else {
-#if (PY_VERSION_HEX < 0x02020000)
- data->newraw = 0;
-#else
- data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
-#endif
- if (data->newraw) {
- Py_INCREF(data->newraw);
- data->newargs = PyTuple_New(1);
- PyTuple_SetItem(data->newargs, 0, obj);
- } else {
- data->newargs = obj;
- }
- Py_INCREF(data->newargs);
- }
- /* the destroy method, aka as the C++ delete method */
- data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
- if (PyErr_Occurred()) {
- PyErr_Clear();
- data->destroy = 0;
- }
- if (data->destroy) {
- int flags;
- Py_INCREF(data->destroy);
- flags = PyCFunction_GET_FLAGS(data->destroy);
-#ifdef METH_O
- data->delargs = !(flags & (METH_O));
-#else
- data->delargs = 0;
-#endif
- } else {
- data->delargs = 0;
- }
- data->implicitconv = 0;
- return data;
- }
-}
-
-SWIGRUNTIME void
-PySwigClientData_Del(PySwigClientData* data)
-{
- Py_XDECREF(data->newraw);
- Py_XDECREF(data->newargs);
- Py_XDECREF(data->destroy);
-}
-
-/* =============== PySwigObject =====================*/
-
-typedef struct {
- PyObject_HEAD
- void *ptr;
- swig_type_info *ty;
- int own;
- PyObject *next;
-} PySwigObject;
-
-SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
-{
- return PyLong_FromVoidPtr(v->ptr);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
-{
- PyObject *res = NULL;
- PyObject *args = PyTuple_New(1);
- if (args) {
- if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
- PyObject *ofmt = PyString_FromString(fmt);
- if (ofmt) {
- res = PyString_Format(ofmt,args);
- Py_DECREF(ofmt);
- }
- Py_DECREF(args);
- }
- }
- return res;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
-{
- return PySwigObject_format("%o",v);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
-{
- return PySwigObject_format("%x",v);
-}
-
-SWIGRUNTIME PyObject *
-#ifdef METH_NOARGS
-PySwigObject_repr(PySwigObject *v)
-#else
-PySwigObject_repr(PySwigObject *v, PyObject *args)
-#endif
-{
- const char *name = SWIG_TypePrettyName(v->ty);
- PyObject *hex = PySwigObject_hex(v);
- PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
- Py_DECREF(hex);
- if (v->next) {
-#ifdef METH_NOARGS
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
-#else
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
-#endif
- PyString_ConcatAndDel(&repr,nrep);
- }
- return repr;
-}
-
-SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
-#ifdef METH_NOARGS
- PyObject *repr = PySwigObject_repr(v);
-#else
- PyObject *repr = PySwigObject_repr(v, NULL);
-#endif
- if (repr) {
- fputs(PyString_AsString(repr), fp);
- Py_DECREF(repr);
- return 0;
- } else {
- return 1;
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
-{
- char result[SWIG_BUFFER_SIZE];
- return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
- PyString_FromString(result) : 0;
-}
-
-SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
-{
- void *i = v->ptr;
- void *j = w->ptr;
- return (i < j) ? -1 : ((i > j) ? 1 : 0);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
- return ((op)->ob_type == PySwigObject_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own);
-
-SWIGRUNTIME void
-PySwigObject_dealloc(PyObject *v)
-{
- PySwigObject *sobj = (PySwigObject *) v;
- PyObject *next = sobj->next;
- if (sobj->own) {
- swig_type_info *ty = sobj->ty;
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- PyObject *destroy = data ? data->destroy : 0;
- if (destroy) {
- /* destroy is always a VARARGS method */
- PyObject *res;
- if (data->delargs) {
- /* we need to create a temporal object to carry the destroy operation */
- PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
- res = SWIG_Python_CallFunctor(destroy, tmp);
- Py_DECREF(tmp);
- } else {
- PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
- PyObject *mself = PyCFunction_GET_SELF(destroy);
- res = ((*meth)(mself, v));
- }
- Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
- }
- }
- Py_XDECREF(next);
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyObject*
-PySwigObject_append(PyObject* v, PyObject* next)
-{
- PySwigObject *sobj = (PySwigObject *) v;
-#ifndef METH_O
- PyObject *tmp = 0;
- if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
- next = tmp;
-#endif
- if (!PySwigObject_Check(next)) {
- return NULL;
- }
- sobj->next = next;
- Py_INCREF(next);
- return SWIG_Py_Void();
-}
-
-SWIGRUNTIME PyObject*
-#ifdef METH_NOARGS
-PySwigObject_next(PyObject* v)
-#else
-PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *) v;
- if (sobj->next) {
- Py_INCREF(sobj->next);
- return sobj->next;
- } else {
- return SWIG_Py_Void();
- }
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_disown(PyObject *v)
-#else
-PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = 0;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_acquire(PyObject *v)
-#else
-PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = SWIG_POINTER_OWN;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-PySwigObject_own(PyObject *v, PyObject *args)
-{
- PyObject *val = 0;
-#if (PY_VERSION_HEX < 0x02020000)
- if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#else
- if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
-#endif
- {
- return NULL;
- }
- else
- {
- PySwigObject *sobj = (PySwigObject *)v;
- PyObject *obj = PyBool_FromLong(sobj->own);
- if (val) {
-#ifdef METH_NOARGS
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v);
- } else {
- PySwigObject_disown(v);
- }
-#else
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v,args);
- } else {
- PySwigObject_disown(v,args);
- }
-#endif
- }
- return obj;
- }
-}
-
-#ifdef METH_O
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#else
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#endif
-
-#if PY_VERSION_HEX < 0x02020000
-SWIGINTERN PyObject *
-PySwigObject_getattr(PySwigObject *sobj,char *name)
-{
- return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
-}
-#endif
-
-SWIGRUNTIME PyTypeObject*
-_PySwigObject_type(void) {
- static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
-
- static PyNumberMethods PySwigObject_as_number = {
- (binaryfunc)0, /*nb_add*/
- (binaryfunc)0, /*nb_subtract*/
- (binaryfunc)0, /*nb_multiply*/
- (binaryfunc)0, /*nb_divide*/
- (binaryfunc)0, /*nb_remainder*/
- (binaryfunc)0, /*nb_divmod*/
- (ternaryfunc)0,/*nb_power*/
- (unaryfunc)0, /*nb_negative*/
- (unaryfunc)0, /*nb_positive*/
- (unaryfunc)0, /*nb_absolute*/
- (inquiry)0, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- (coercion)0, /*nb_coerce*/
- (unaryfunc)PySwigObject_long, /*nb_int*/
- (unaryfunc)PySwigObject_long, /*nb_long*/
- (unaryfunc)0, /*nb_float*/
- (unaryfunc)PySwigObject_oct, /*nb_oct*/
- (unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000
- 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
-#endif
- };
-
- static PyTypeObject pyswigobject_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigObject", /* tp_name */
- sizeof(PySwigObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigObject_dealloc, /* tp_dealloc */
- (printfunc)PySwigObject_print, /* tp_print */
-#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)PySwigObject_getattr, /* tp_getattr */
-#else
- (getattrfunc)0, /* tp_getattr */
-#endif
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigObject_compare, /* tp_compare */
- (reprfunc)PySwigObject_repr, /* tp_repr */
- &PySwigObject_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigObject_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigobject_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- swigobject_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigobject_type = tmp;
- pyswigobject_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigobject_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own)
-{
- PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
- if (sobj) {
- sobj->ptr = ptr;
- sobj->ty = ty;
- sobj->own = own;
- sobj->next = 0;
- }
- return (PyObject *)sobj;
-}
-
-/* -----------------------------------------------------------------------------
- * Implements a simple Swig Packed type, and use it instead of string
- * ----------------------------------------------------------------------------- */
-
-typedef struct {
- PyObject_HEAD
- void *pack;
- swig_type_info *ty;
- size_t size;
-} PySwigPacked;
-
-SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
- char result[SWIG_BUFFER_SIZE];
- fputs("<Swig Packed ", fp);
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- fputs("at ", fp);
- fputs(result, fp);
- }
- fputs(v->ty->name,fp);
- fputs(">", fp);
- return 0;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
- } else {
- return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
- return PyString_FromFormat("%s%s", result, v->ty->name);
- } else {
- return PyString_FromString(v->ty->name);
- }
-}
-
-SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
-{
- size_t i = v->size;
- size_t j = w->size;
- int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
- return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
- return ((op)->ob_type == _PySwigPacked_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
-}
-
-SWIGRUNTIME void
-PySwigPacked_dealloc(PyObject *v)
-{
- if (PySwigPacked_Check(v)) {
- PySwigPacked *sobj = (PySwigPacked *) v;
- free(sobj->pack);
- }
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyTypeObject*
-_PySwigPacked_type(void) {
- static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyTypeObject pyswigpacked_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigPacked", /* tp_name */
- sizeof(PySwigPacked), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigPacked_dealloc, /* tp_dealloc */
- (printfunc)PySwigPacked_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigPacked_compare, /* tp_compare */
- (reprfunc)PySwigPacked_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigPacked_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigpacked_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigpacked_type = tmp;
- pyswigpacked_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigpacked_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
-{
- PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
- if (sobj) {
- void *pack = malloc(size);
- if (pack) {
- memcpy(pack, ptr, size);
- sobj->pack = pack;
- sobj->ty = ty;
- sobj->size = size;
- } else {
- PyObject_DEL((PyObject *) sobj);
- sobj = 0;
- }
- }
- return (PyObject *) sobj;
-}
-
-SWIGRUNTIME swig_type_info *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
-{
- if (PySwigPacked_Check(obj)) {
- PySwigPacked *sobj = (PySwigPacked *)obj;
- if (sobj->size != size) return 0;
- memcpy(ptr, sobj->pack, size);
- return sobj->ty;
- } else {
- return 0;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * pointers/data manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_This(void)
-{
- return PyString_FromString("this");
-}
-
-SWIGRUNTIME PyObject *
-SWIG_This(void)
-{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
- return swig_this;
-}
-
-/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
-
-SWIGRUNTIME PySwigObject *
-SWIG_Python_GetSwigThis(PyObject *pyobj)
-{
- if (PySwigObject_Check(pyobj)) {
- return (PySwigObject *) pyobj;
- } else {
- PyObject *obj = 0;
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
- if (PyInstance_Check(pyobj)) {
- obj = _PyInstance_Lookup(pyobj, SWIG_This());
- } else {
- PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
- } else {
-#ifdef PyWeakref_CheckProxy
- if (PyWeakref_CheckProxy(pyobj)) {
- PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
- return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
- }
-#endif
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
- }
- }
-#else
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
-#endif
- if (obj && !PySwigObject_Check(obj)) {
- /* a PyObject is called 'this', try to get the 'real this'
- PySwigObject from it */
- return SWIG_Python_GetSwigThis(obj);
- }
- return (PySwigObject *)obj;
- }
...
[truncated message content] |
|
From: <evi...@us...> - 2009-07-17 18:44:37
|
Revision: 7267
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7267&view=rev
Author: evilguru
Date: 2009-07-17 18:44:30 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
Port the GDK backend over to mathtex.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_gdk.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_gdk.py 2009-07-17 15:24:27 UTC (rev 7266)
+++ branches/mathtex/lib/matplotlib/backends/backend_gdk.py 2009-07-17 18:44:30 UTC (rev 7267)
@@ -24,10 +24,11 @@
FigureManagerBase, FigureCanvasBase
from matplotlib.cbook import is_string_like
from matplotlib.figure import Figure
-from matplotlib.mathtext import MathTextParser
from matplotlib.transforms import Affine2D
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_image import MathtexBackendImage
backend_version = "%d.%d.%d" % gtk.pygtk_version
_debug = False
@@ -71,7 +72,6 @@
self.gtkDA = gtkDA
self.dpi = dpi
self._cmap = gtkDA.get_colormap()
- self.mathtext_parser = MathTextParser("Agg")
def set_pixmap (self, pixmap):
self.gdkDrawable = pixmap
@@ -159,9 +159,14 @@
def _draw_mathtext(self, gc, x, y, s, prop, angle):
- ox, oy, width, height, descent, font_image, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
+ m = Mathtex(s, matplotlib.rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), self.dpi)
+ b = MathtexBackendImage()
+ m.render_to_backend(b)
+ width, height = m.width, m.height + m.depth
+ font_image = b.image
+
if angle==90:
width, height = height, width
x -= width
@@ -300,9 +305,9 @@
def get_text_width_height_descent(self, s, prop, ismath):
if ismath:
- ox, oy, width, height, descent, font_image, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- return width, height, descent
+ m = Mathtex(s, matplotlib.rcParams['mathtext.fontset'],
+ prop.get_size_in_points(), self.dpi)
+ return m.width, m.height, m.depth
layout, inkRect, logicalRect = self._get_pango_layout(s, prop)
l, b, w, h = inkRect
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-17 15:24:30
|
Revision: 7266
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7266&view=rev
Author: evilguru
Date: 2009-07-17 15:24:27 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
Port the AGG backend over to mathtex. More testing still needed.
Modified Paths:
--------------
branches/mathtex/lib/matplotlib/backends/backend_agg.py
Modified: branches/mathtex/lib/matplotlib/backends/backend_agg.py
===================================================================
--- branches/mathtex/lib/matplotlib/backends/backend_agg.py 2009-07-17 07:24:06 UTC (rev 7265)
+++ branches/mathtex/lib/matplotlib/backends/backend_agg.py 2009-07-17 15:24:27 UTC (rev 7266)
@@ -31,13 +31,15 @@
from matplotlib.figure import Figure
from matplotlib.font_manager import findfont
from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT
-from matplotlib.mathtext import MathTextParser
from matplotlib.path import Path
from matplotlib.transforms import Bbox, BboxBase
from _backend_agg import RendererAgg as _RendererAgg
from matplotlib import _png
+from mathtex.mathtex_main import Mathtex
+from mathtex.backends.backend_image import MathtexBackendImage
+
backend_version = 'v2.2'
class RendererAgg(RendererBase):
@@ -66,7 +68,6 @@
self.draw_image = self._renderer.draw_image
self.copy_from_bbox = self._renderer.copy_from_bbox
self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
- self.mathtext_parser = MathTextParser('Agg')
self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
if __debug__: verbose.report('RendererAgg.__init__ done',
@@ -99,17 +100,17 @@
def draw_mathtext(self, gc, x, y, s, prop, angle):
"""
- Draw the math text using matplotlib.mathtext
+ Draw the math text using mathtex.mathtex_main
"""
if __debug__: verbose.report('RendererAgg.draw_mathtext',
'debug-annoying')
- ox, oy, width, height, descent, font_image, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), self.dpi)
+ b = MathtexBackendImage()
- x = int(x) + ox
- y = int(y) - oy
- self._renderer.draw_text_image(font_image, x, y + 1, angle, gc)
+ m.render_to_backend(b)
+ self._renderer.draw_text_image(b.image, int(x), int(y) + 1, angle, gc)
+
def draw_text(self, gc, x, y, s, prop, angle, ismath):
"""
Render the text
@@ -152,9 +153,8 @@
return w, h, d
if ismath:
- ox, oy, width, height, descent, fonts, used_characters = \
- self.mathtext_parser.parse(s, self.dpi, prop)
- return width, height, descent
+ m = Mathtex(s, rcParams['mathtext.fontset'], prop.get_size_in_points(), self.dpi)
+ return m.width, m.height, m.depth
font = self._get_agg_font(prop)
font.set_text(s, 0.0, flags=LOAD_FORCE_AUTOHINT) # the width and height of unrotated string
w, h = font.get_width_height()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2009-07-17 07:24:08
|
Revision: 7265
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7265&view=rev
Author: heeres
Date: 2009-07-17 07:24:06 +0000 (Fri, 17 Jul 2009)
Log Message:
-----------
mplot3d: add bar3d, improve z-sort, hist3d example
Modified Paths:
--------------
trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
Added Paths:
-----------
trunk/matplotlib/examples/mplot3d/hist3d_demo.py
Added: trunk/matplotlib/examples/mplot3d/hist3d_demo.py
===================================================================
--- trunk/matplotlib/examples/mplot3d/hist3d_demo.py (rev 0)
+++ trunk/matplotlib/examples/mplot3d/hist3d_demo.py 2009-07-17 07:24:06 UTC (rev 7265)
@@ -0,0 +1,27 @@
+from mpl_toolkits.mplot3d import Axes3D
+from matplotlib.collections import PolyCollection
+from matplotlib.colors import colorConverter
+import pylab
+import random
+import numpy as np
+
+fig = pylab.figure()
+ax = Axes3D(fig)
+x = np.random.rand(100) * 4
+y = np.random.rand(100) * 4
+hist, xedges, yedges = np.histogram2d(x, y, bins=4)
+
+elements = (len(xedges) - 1) * (len(yedges) - 1)
+xpos, ypos = np.meshgrid(
+ [xedges[i] + 0.25 for i in range(len(xedges) - 1)],
+ [yedges[i] + 0.25 for i in range(len(yedges) - 1)])
+xpos = xpos.flatten()
+ypos = ypos.flatten()
+zpos = [0] * elements
+dx = [0.5] * elements
+dy = [0.5] * elements
+dz = hist.flatten()
+ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b')
+
+pylab.show()
+
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-07-16 20:53:24 UTC (rev 7264)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/art3d.py 2009-07-17 07:24:06 UTC (rev 7265)
@@ -271,6 +271,7 @@
PolyCollection.__init__(self, verts, *args, **kwargs)
self._zsort = 1
+ self._sort_zpos = None
def get_vector(self, segments3d):
"""Optimize points for projection"""
@@ -287,7 +288,6 @@
ones = np.ones(len(xs))
self._vec = np.array([xs, ys, zs, ones])
self._segis = segis
- self._sort_zpos = min(zs)
def set_verts(self, verts, closed=True):
'''Set 3D vertices.'''
@@ -297,9 +297,13 @@
def set_3d_properties(self):
self._zsort = 1
+ self._sort_zpos = None
self._facecolors3d = PolyCollection.get_facecolors(self)
self._edgecolors3d = PolyCollection.get_edgecolors(self)
+ def set_sort_zpos(self, val):
+ self._sort_zpos = val
+
def do_3d_projection(self, renderer):
'''
Perform the 3D projection for this object.
@@ -315,17 +319,19 @@
# This extra fuss is to re-order face / edge colors
cface = self._facecolors3d
- if len(self._edgecolors3d) != len(cface):
- cedge = cface
- else:
- cedge = self._edgecolors3d
+ cedge = self._edgecolors3d
+ if len(cface) != len(xyzlist):
+ cface = cface.repeat(len(xyzlist), axis=0)
+ if len(cedge) != len(xyzlist):
+ if len(cedge) == 0:
+ cedge = cface
+ cedge = cedge.repeat(len(xyzlist), axis=0)
# if required sort by depth (furthest drawn first)
if self._zsort:
- z_segments_2d = [(min(zs), zip(xs, ys), fc, ec) for
+ z_segments_2d = [(np.average(zs), zip(xs, ys), fc, ec) for
(xs, ys, zs), fc, ec in zip(xyzlist, cface, cedge)]
- z_segments_2d.sort()
- z_segments_2d.reverse()
+ z_segments_2d.sort(reverse=True)
else:
raise ValueError, "whoops"
@@ -339,9 +345,12 @@
self._edgecolors2d = self._edgecolors3d
# Return zorder value
- zvec = np.array([[0], [0], [self._sort_zpos], [1]])
- ztrans = proj3d.proj_transform_vec(zvec, renderer.M)
- return ztrans[2][0]
+ if self._sort_zpos is not None:
+ zvec = np.array([[0], [0], [self._sort_zpos], [1]])
+ ztrans = proj3d.proj_transform_vec(zvec, renderer.M)
+ return ztrans[2][0]
+ else:
+ return np.min(tzs)
def set_facecolor(self, colors):
PolyCollection.set_facecolor(self, colors)
Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-16 20:53:24 UTC (rev 7264)
+++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-17 07:24:06 UTC (rev 7265)
@@ -625,6 +625,20 @@
return polyc
+ def _generate_normals(self, polygons):
+ '''
+ Generate normals for polygons by using the first three points.
+ This normal of course might not make sense for polygons with
+ more than three points not lying in a plane.
+ '''
+
+ normals = []
+ for verts in polygons:
+ v1 = np.array(verts[0]) - np.array(verts[1])
+ v2 = np.array(verts[2]) - np.array(verts[0])
+ normals.append(np.cross(v1, v2))
+ return normals
+
def _shade_colors(self, color, normals):
shade = []
for n in normals:
@@ -733,6 +747,7 @@
colors2 = self._shade_colors(color, normals)
polycol = art3d.Poly3DCollection(polyverts, facecolors=colors,
edgecolors=colors2)
+ polycol.set_sort_zpos(z)
self.add_collection3d(polycol)
for col in colls:
@@ -792,6 +807,7 @@
colls = cset.collections
for z1, z2, linec in zip(levels, levels[1:], colls):
art3d.poly_collection_2d_to_3d(linec, z1)
+ linec.set_sort_zpos(z1)
self.auto_scale_xyz(X, Y, Z, had_data)
return cset
@@ -813,10 +829,13 @@
if type(col) is collections.PolyCollection:
art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir)
+ col.set_sort_zpos(min(zs))
elif type(col) is collections.LineCollection:
art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir)
+ col.set_sort_zpos(min(zs))
elif type(col) is collections.PatchCollection:
art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir)
+ col.set_sort_zpos(min(zs))
Axes.add_collection(self, col)
@@ -902,6 +921,64 @@
return patches
+ def bar3d(self, x, y, z, dx, dy, dz, color='b'):
+ '''
+ Generate a 3D bar, or multiple bars.
+
+ When generating multiple bars, x, y, z have to be arrays.
+ dx, dy, dz can still be scalars.
+ '''
+
+ had_data = self.has_data()
+
+ if not cbook.iterable(x):
+ print 'not interable'
+ x, y, z = [x], [y], [z]
+ if not cbook.iterable(dx):
+ dx, dy, dz = [dx], [dy], [dz]
+ if len(dx) == 1:
+ dx = dx * len(x)
+ dy = dy * len(x)
+ dz = dz * len(x)
+
+ minx, miny, minz = 1e20, 1e20, 1e20
+ maxx, maxy, maxz = -1e20, -1e20, -1e20
+
+ polys = []
+ for xi, yi, zi, dxi, dyi, dzi in zip(x, y, z, dx, dy, dz):
+ minx = min(xi, minx)
+ maxx = max(xi + dxi, maxx)
+ miny = min(yi, miny)
+ maxy = max(yi + dyi, maxy)
+ minz = min(zi, minz)
+ maxz = max(zi + dzi, maxz)
+
+ polys.extend([
+ ((xi, yi, zi), (xi + dxi, yi, zi),
+ (xi + dxi, yi + dyi, zi), (xi, yi + dyi, zi)),
+ ((xi, yi, zi + dzi), (xi + dxi, yi, zi + dzi),
+ (xi + dxi, yi + dyi, zi + dzi), (xi, yi + dyi, zi + dzi)),
+
+ ((xi, yi, zi), (xi + dxi, yi, zi),
+ (xi + dxi, yi, zi + dzi), (xi, yi, zi + dzi)),
+ ((xi, yi + dyi, zi), (xi + dxi, yi + dyi, zi),
+ (xi + dxi, yi + dyi, zi + dzi), (xi, yi + dyi, zi + dzi)),
+
+ ((xi, yi, zi), (xi, yi + dyi, zi),
+ (xi, yi + dyi, zi + dzi), (xi, yi, zi + dzi)),
+ ((xi + dxi, yi, zi), (xi + dxi, yi + dyi, zi),
+ (xi + dxi, yi + dyi, zi + dzi), (xi + dxi, yi, zi + dzi)),
+ ])
+
+ color = np.array(colorConverter.to_rgba(color))
+ normals = self._generate_normals(polys)
+ colors = self._shade_colors(color, normals)
+
+ col = art3d.Poly3DCollection(polys, facecolor=colors)
+ self.add_collection(col)
+
+ self.auto_scale_xyz((minx, maxx), (miny, maxy), (minz, maxz), had_data)
+
def get_test_data(delta=0.05):
'''
Return a tuple X, Y, Z with a test data set.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-16 20:53:27
|
Revision: 7264
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7264&view=rev
Author: evilguru
Date: 2009-07-16 20:53:24 +0000 (Thu, 16 Jul 2009)
Log Message:
-----------
Add merge tracking to the mathtex branch.
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <evi...@us...> - 2009-07-16 20:49:03
|
Revision: 7263
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7263&view=rev
Author: evilguru
Date: 2009-07-16 20:48:57 +0000 (Thu, 16 Jul 2009)
Log Message:
-----------
Creating a branch for mathtex integration.
Added Paths:
-----------
branches/mathtex/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|