You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
1
(7) |
2
(14) |
3
(6) |
4
(8) |
5
(6) |
6
(3) |
7
(2) |
8
(22) |
9
(9) |
10
(23) |
11
(14) |
12
(22) |
13
(7) |
14
(3) |
15
(22) |
16
(13) |
17
(18) |
18
(21) |
19
(9) |
20
|
21
(3) |
22
(6) |
23
(5) |
24
|
25
|
26
(3) |
27
|
28
(1) |
29
(11) |
30
(1) |
31
(12) |
|
|
|
Revision: 6687 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6687&view=rev Author: leejjoon Date: 2008年12月19日 22:48:11 +0000 (2008年12月19日) Log Message: ----------- axes_locator in the Axes class Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/axes_divider.py trunk/matplotlib/examples/pylab_examples/axes_grid.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年12月19日 21:41:11 UTC (rev 6686) +++ trunk/matplotlib/CHANGELOG 2008年12月19日 22:48:11 UTC (rev 6687) @@ -1,3 +1,6 @@ +2008年12月19日 Add axes_locator attribute in Axes. Two examples are added. + - JJL + 2008年12月19日 Update Axes.legend documnetation. /api/api_changes.rst is also updated to describe chages in keyword parameters. Issue a warning if old keyword parameters are used. - JJL Added: trunk/matplotlib/examples/pylab_examples/axes_divider.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/axes_divider.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/axes_divider.py 2008年12月19日 22:48:11 UTC (rev 6687) @@ -0,0 +1,638 @@ + +import matplotlib.axes as maxes +import matplotlib.transforms as mtransforms + +import matplotlib.cbook as cbook + +import new + + +class Size(object): + + @classmethod + def from_any(self, size, fraction_ref=None): + if cbook.is_numlike(size): + return Size.Fixed(size) + elif cbook.is_string_like(size): + if size[-1] == "%": + return Size.Fraction(fraction_ref, float(size[:-1])/100.) + + raise ValueError("") + + + + class _Base(object): + pass + + class Fixed(_Base): + def __init__(self, fixed_size): + self._fixed_size = fixed_size + + def get_size(self, renderer): + rel_size = 0. + abs_size = self._fixed_size + return rel_size, abs_size + + class Scalable(_Base): + def __init__(self, scalable_size): + self._scalable_size = scalable_size + + def get_size(self, renderer): + rel_size = self._scalable_size + abs_size = 0. + return rel_size, abs_size + + + class AxesX(_Base): + def __init__(self, axes, aspect=1.): + self._axes = axes + self._aspect = aspect + + def get_size(self, renderer): + l1, l2 = self._axes.get_xlim() + rel_size = abs(l2-l1)*self._aspect + abs_size = 0. + return rel_size, abs_size + + class AxesY(_Base): + def __init__(self, axes, aspect=1.): + self._axes = axes + self._aspect = aspect + + def get_size(self, renderer): + l1, l2 = self._axes.get_ylim() + rel_size = abs(l2-l1)*self._aspect + abs_size = 0. + return rel_size, abs_size + + + class MaxExtent(_Base): + def __init__(self, artist_list, w_or_h): + self._artist_list = artist_list + + if w_or_h not in ["width", "height"]: + raise ValueError() + + self._w_or_h = w_or_h + + def add_artist(self, a): + self._artist_list.append(a) + + def get_size(self, renderer): + rel_size = 0. + w_list, h_list = [], [] + for a in self._artist_list: + bb = a.get_window_extent(renderer) + w_list.append(bb.width) + h_list.append(bb.height) + dpi = a.get_figure().get_dpi() + if self._w_or_h == "width": + abs_size = max(w_list)/dpi + elif self._w_or_h == "height": + abs_size = max(h_list)/dpi + + return rel_size, abs_size + + class Fraction(_Base): + def __init__(self, size, fraction): + self._size = size + self._fraction = fraction + + def get_size(self, renderer): + r, a = self._size.get_size(renderer) + rel_size = r*self._fraction + abs_size = a*self._fraction + return rel_size, abs_size + + class Padded(_Base): + def __init__(self, size, pad): + self._size = size + self._pad = pad + + def get_size(self, renderer): + r, a = self._size.get_size(renderer) + rel_size = r + abs_size = a + self._pad + return rel_size, abs_size + + + +class AxesLocator(object): + def __init__(self, axes_divider, nx, ny, nx1=None, ny1=None): + + self._axes_divider = axes_divider + + _xrefindex = axes_divider._xrefindex + _yrefindex = axes_divider._yrefindex + + self._nx, self._ny = nx - _xrefindex, ny - _yrefindex + + if nx1 is None: + nx1 = nx+1 + if ny1 is None: + ny1 = ny+1 + + self._nx1 = nx1 - _xrefindex + self._ny1 = ny1 - _yrefindex + + + def __call__(self, axes, renderer): + + _xrefindex = self._axes_divider._xrefindex + _yrefindex = self._axes_divider._yrefindex + + return self._axes_divider.locate(self._nx + _xrefindex, self._ny + _yrefindex, + self._nx1 + _xrefindex, self._ny1 + _yrefindex, + renderer) + + +class Divider(object): + + def __init__(self, fig, pos, horizontal, vertical, aspect=None, anchor="C"): + self._fig = fig + self._pos = pos + self._horizontal = horizontal + self._vertical = vertical + self._anchor = anchor + self._aspect = aspect + self._xrefindex = 0 + self._yrefindex = 0 + + + @staticmethod + def _calc_k(l, total_size, renderer): + + rs_sum, as_sum = 0., 0. + + for s in l: + rs, as = s.get_size(renderer) + rs_sum += rs + as_sum += as + + k = (total_size - as_sum) / rs_sum + return k + + + @staticmethod + def _calc_offsets(l, k, renderer): + + offsets = [0.] + + for s in l: + rs, as = s.get_size(renderer) + offsets.append(offsets[-1] + rs*k + as) + + return offsets + + + def set_position(self, pos): + self._pos = pos + + def get_position(self): + return self._pos + + def set_anchor(self, anchor): + """ + *anchor* + + ===== ============ + value description + ===== ============ + 'C' Center + 'SW' bottom left + 'S' bottom + 'SE' bottom right + 'E' right + 'NE' top right + 'N' top + 'NW' top left + 'W' left + ===== ============ + + """ + if anchor in mtransforms.Bbox.coefs.keys() or len(anchor) == 2: + self._anchor = anchor + else: + raise ValueError('argument must be among %s' % + ', '.join(mtransforms.BBox.coefs.keys())) + + + def set_horizontal(self, h): + self._horizontal = h + + def get_horizontal(self): + return self._horizontal + + def set_vertical(self, v): + self._vertical = v + + def get_vertical(self): + return self._vertical + + + def get_anchor(self): + return self._anchor + + + def set_aspect(self, aspect=False): + """ + *aspect* : True or False + """ + self._aspect = aspect + + def get_aspect(self): + return self._aspect + + + def locate(self, nx, ny, nx1=None, ny1=None, renderer=None): + + + figW,figH = self._fig.get_size_inches() + x, y, w, h = self.get_position() + + k_h = self._calc_k(self._horizontal, figW*w, renderer) + k_v = self._calc_k(self._vertical, figH*h, renderer) + + if self.get_aspect(): + k = min(k_h, k_v) + ox = self._calc_offsets(self._horizontal, k, renderer) + oy = self._calc_offsets(self._vertical, k, renderer) + else: + ox = self._calc_offsets(self._horizontal, k_h, renderer) + oy = self._calc_offsets(self._vertical, k_v, renderer) + + + ww = (ox[-1] - ox[0])/figW + hh = (oy[-1] - oy[0])/figH + pb = mtransforms.Bbox.from_bounds(x, y, w, h) + pb1 = mtransforms.Bbox.from_bounds(x, y, ww, hh) + pb1_anchored = pb1.anchored(self.get_anchor(), pb) + + if nx1 is None: + nx1=nx+1 + if ny1 is None: + ny1=ny+1 + + x0, y0 = pb1_anchored.x0, pb1_anchored.y0 + x1, w1 = x0 + ox[nx]/figW, (ox[nx1] - ox[nx])/figW + y1, h1 = y0 + oy[ny]/figH, (oy[ny1] - oy[ny])/figH + + return mtransforms.Bbox.from_bounds(x1, y1, w1, h1) + + + def new_locator(self, nx, ny, nx1=None, ny1=None): + return AxesLocator(self, nx, ny, nx1, ny1) + + +class SubplotDivider(Divider): + + def __init__(self, fig, *args, **kwargs): + """ + *fig* is a :class:`matplotlib.figure.Figure` instance. + + *args* is the tuple (*numRows*, *numCols*, *plotNum*), where + the array of subplots in the figure has dimensions *numRows*, + *numCols*, and where *plotNum* is the number of the subplot + being created. *plotNum* starts at 1 in the upper left + corner and increases to the right. + + If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the + decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*. + """ + + self.figure = fig + + if len(args)==1: + s = str(args[0]) + if len(s) != 3: + raise ValueError('Argument to subplot must be a 3 digits long') + rows, cols, num = map(int, s) + elif len(args)==3: + rows, cols, num = args + else: + raise ValueError( 'Illegal argument to subplot') + + + total = rows*cols + num -= 1 # convert from matlab to python indexing + # ie num in range(0,total) + if num >= total: + raise ValueError( 'Subplot number exceeds total subplots') + self._rows = rows + self._cols = cols + self._num = num + + self.update_params() + + pos = self.figbox.bounds + horizontal = kwargs.pop("horizontal", []) + vertical = kwargs.pop("vertical", []) + aspect = kwargs.pop("aspect", None) + anchor = kwargs.pop("anchor", "C") + + if kwargs: + raise Exception("") + + Divider.__init__(self, fig, pos, horizontal, vertical, + aspect=aspect, anchor=anchor) + + + def get_position(self): + self.update_params() + return self.figbox.bounds + + + def update_params(self): + 'update the subplot position from fig.subplotpars' + + rows = self._rows + cols = self._cols + num = self._num + + pars = self.figure.subplotpars + left = pars.left + right = pars.right + bottom = pars.bottom + top = pars.top + wspace = pars.wspace + hspace = pars.hspace + totWidth = right-left + totHeight = top-bottom + + figH = totHeight/(rows + hspace*(rows-1)) + sepH = hspace*figH + + figW = totWidth/(cols + wspace*(cols-1)) + sepW = wspace*figW + + rowNum, colNum = divmod(num, cols) + + figBottom = top - (rowNum+1)*figH - rowNum*sepH + figLeft = left + colNum*(figW + sepW) + + self.figbox = mtransforms.Bbox.from_bounds(figLeft, figBottom, + figW, figH) + +class AxesDivider(Divider): + + + def __init__(self, axes): + self._axes = axes + self._xref = Size.AxesX(axes) + self._yref = Size.AxesY(axes) + Divider.__init__(self, fig=axes.get_figure(), pos=None, + horizontal=[self._xref], vertical=[self._yref], + aspect=None, anchor="C") + + def new_horizontal(self, size, pad=None, pack_start=False): + + if pad: + if not isinstance(pad, Size._Base): + pad = Size.from_any(pad, + fraction_ref=self._xref) + if pack_start: + self._horizontal.insert(0, pad) + self._xrefindex += 1 + else: + self._horizontal.append(pad) + + if not isinstance(size, Size._Base): + size = Size.from_any(size, + fraction_ref=self._xref) + + if pack_start: + self._horizontal.insert(0, pad) + self._xrefindex += 1 + locator = self.new_locator(nx=0, ny=0) + else: + self._horizontal.append(size) + locator = self.new_locator(nx=len(self._horizontal)-1, ny=0) + + ax = LocatableAxes(self._axes.get_figure(), + self._axes.get_position(original=True)) + locator = self.new_locator(nx=len(self._horizontal)-1, ny=0) + ax.set_axes_locator(locator) + + return ax + + def new_vertical(self, size, pad=None, pack_start=False): + + if pad: + if not isinstance(pad, Size._Base): + pad = Size.from_any(pad, + fraction_ref=self._yref) + if pack_start: + self._vertical.insert(0, pad) + self._yrefindex += 1 + else: + self._vertical.append(pad) + + if not isinstance(size, Size._Base): + size = Size.from_any(size, + fraction_ref=self._yref) + + if pack_start: + self._vertical.insert(0, pad) + self._yrefindex += 1 + locator = self.new_locator(nx=0, ny=0) + else: + self._vertical.append(size) + locator = self.new_locator(nx=0, ny=len(self._vertical)-1) + + ax = LocatableAxes(self._axes.get_figure(), + self._axes.get_position(original=True)) + ax.set_axes_locator(locator) + + return ax + + + def get_aspect(self): + if self._aspect is None: + aspect = self._axes.get_aspect() + if aspect == "auto": + return False + else: + return True + else: + return self._aspect + + def get_position(self): + if self._pos is None: + bbox = self._axes.get_position(original=True) + return bbox.bounds + else: + return self._pos + + def get_anchor(self): + if self._anchor is None: + return self._axes.get_anchor() + else: + return self._anchor + + + +class LocatableAxesBase: + def __init__(self, *kl, **kw): + + self._axes_class.__init__(self, *kl, **kw) + + self._locator = None + self._locator_renderer = None + + def set_axes_locator(self, locator): + self._locator = locator + + def get_axes_locator(self): + return self._locator + + def apply_aspect(self, position=None): + + if self.get_axes_locator() is None: + self._axes_class.apply_apsect(self, position) + else: + pos = self.get_axes_locator()(self, self._locator_renderer) + self._axes_class.apply_aspect(self, position=pos) + + + def draw(self, renderer=None, inframe=False): + + self._locator_renderer = renderer + + self._axes_class.draw(self, renderer, inframe) + + + +_locatableaxes_classes = {} +def locatable_axes_factory(axes_class): + + new_class = _locatableaxes_classes.get(axes_class) + if new_class is None: + new_class = new.classobj("Locatable%s" % (axes_class.__name__), + (LocatableAxesBase, axes_class), + {'_axes_class': axes_class}) + _locatableaxes_classes[axes_class] = new_class + + return new_class + +if hasattr(maxes.Axes, "get_axes_locator"): + LocatableAxes = maxes.Axes +else: + LocatableAxes = locatable_axes_factory(maxes.Axes) + + +def make_axes_locatable(axes): + if not hasattr(axes, "set_axes_locator"): + new_class = locatable_axes_factory(type(axes)) + axes.__class__ = new_class + + divider = AxesDivider(axes) + locator = divider.new_locator(nx=0, ny=0) + axes.set_axes_locator(locator) + + return divider + + +def get_demo_image(): + # prepare image + delta = 0.5 + + extent = (-3,4,-4,3) + import numpy as np + x = np.arange(-3.0, 4.001, delta) + y = np.arange(-4.0, 3.001, delta) + X, Y = np.meshgrid(x, y) + import matplotlib.mlab as mlab + Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) + Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) + Z = (Z1 - Z2) * 10 + + return Z, extent + +def demo_locatable_axes(): + import matplotlib.pyplot as plt + + fig1 = plt.figure(1, (6, 6)) + fig1.clf() + + ## PLOT 1 + # simple image & colorbar + ax = fig1.add_subplot(2, 2, 1) + + Z, extent = get_demo_image() + + im = ax.imshow(Z, extent=extent, interpolation="nearest") + cb = plt.colorbar(im) + plt.setp(cb.ax.get_yticklabels(), visible=False) + + + ## PLOT 2 + # image and colorbar whose location is adjusted in the drawing time. + # a hard way + + divider = SubplotDivider(fig1, 2, 2, 2, aspect=True) + + # axes for image + ax = LocatableAxes(fig1, divider.get_position()) + + # axes for coloarbar + ax_cb = LocatableAxes(fig1, divider.get_position()) + + h = [Size.AxesX(ax), # main axes + Size.Fixed(0.05), # padding, 0.1 inch + Size.Fixed(0.2), # colorbar, 0.3 inch + ] + + v = [Size.AxesY(ax)] + + divider.set_horizontal(h) + divider.set_vertical(v) + + ax.set_axes_locator(divider.new_locator(nx=0, ny=0)) + ax_cb.set_axes_locator(divider.new_locator(nx=2, ny=0)) + + fig1.add_axes(ax) + fig1.add_axes(ax_cb) + + ax_cb.yaxis.set_ticks_position("right") + + Z, extent = get_demo_image() + + im = ax.imshow(Z, extent=extent, interpolation="nearest") + plt.colorbar(im, cax=ax_cb) + plt.setp(ax_cb.get_yticklabels(), visible=False) + + plt.draw() + #plt.colorbar(im, cax=ax_cb) + + + ## PLOT 3 + # image and colorbar whose location is adjusted in the drawing time. + # a easy way + + ax = fig1.add_subplot(2, 2, 3) + divider = make_axes_locatable(ax) + + ax_cb = divider.new_horizontal(size="5%", pad=0.05) + fig1.add_axes(ax_cb) + + im = ax.imshow(Z, extent=extent, interpolation="nearest") + plt.colorbar(im, cax=ax_cb) + plt.setp(ax_cb.get_yticklabels(), visible=False) + + + ## PLOT 4 + # two images side by sied with fixed padding. + + ax = fig1.add_subplot(2, 2, 4) + divider = make_axes_locatable(ax) + + ax2 = divider.new_horizontal(size="100%", pad=0.05) + fig1.add_axes(ax2) + + ax.imshow(Z, extent=extent, interpolation="nearest") + ax2.imshow(Z, extent=extent, interpolation="nearest") + plt.setp(ax2.get_yticklabels(), visible=False) + plt.draw() + +if __name__ == "__main__": + demo_locatable_axes() Added: trunk/matplotlib/examples/pylab_examples/axes_grid.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/axes_grid.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/axes_grid.py 2008年12月19日 22:48:11 UTC (rev 6687) @@ -0,0 +1,343 @@ +import matplotlib.cbook as cbook + +import matplotlib.pyplot as plt + +from axes_divider import Size, SubplotDivider, LocatableAxes, Divider, get_demo_image + +class AxesGrid(object): + + def __init__(self, fig, rect, + nrows_ncols, + ngrids = None, + direction="row", + axes_pad = 0.02, + axes_class=None, + add_all=True, + share_all=False, + aspect=True, + label_mode="L", + colorbar_mode=None, + colorbar_location="right", + colorbar_pad=None, + colorbar_size="5%", + ): + + self._nrows, self._ncols = nrows_ncols + + if ngrids is None: + ngrids = self._nrows * self._ncols + else: + if (ngrids > self._nrows * self._ncols) or (ngrids <= 0): + raise Exception("") + + self.ngrids = ngrids + + self._axes_pad = axes_pad + + self._colorbar_mode = colorbar_mode + self._colorbar_location = colorbar_location + if colorbar_pad is None: + self._colorbar_pad = axes_pad + else: + self._colorbar_pad = colorbar_pad + + self._colorbar_size = colorbar_size + + if direction not in ["column", "row"]: + raise Exception("") + + self._direction = direction + + + if axes_class is None: + axes_class = LocatableAxes + + + self.axes_all = [] + self.axes_column = [[] for i in range(self._ncols)] + self.axes_row = [[] for i in range(self._nrows)] + + self.cbar_axes = [] + + h = [] + v = [] + if cbook.is_string_like(rect) or cbook.is_numlike(rect): + self._divider = SubplotDivider(fig, rect, horizontal=h, vertical=v, + aspect=aspect) + elif len(rect) == 3: + kw = dict(horizontal=h, vertical=v, aspect=aspect) + self._divider = SubplotDivider(fig, *rect, **kw) + elif len(rect) == 4: + self._divider = Divider(fig, rect, horizontal=h, vertical=v, + aspect=aspect) + else: + raise Exception("") + + + rect = self._divider.get_position() + + # reference axes + self._column_refax = [None for i in range(self._ncols)] + self._row_refax = [None for i in range(self._nrows)] + self._refax = None + + for i in range(self.ngrids): + + col, row = self.get_col_row(i) + + if share_all: + sharex = self._refax + sharey = self._refax + else: + sharex = self._column_refax[col] + sharey = self._row_refax[row] + + ax = axes_class(fig, rect, sharex=sharex, sharey=sharey) + + if share_all: + if self._refax is None: + self._refax = ax + else: + if sharex is None: + self._column_refax[col] = ax + if sharey is None: + self._row_refax[row] = ax + + self.axes_all.append(ax) + self.axes_column[col].append(ax) + self.axes_row[row].append(ax) + + cax = axes_class(fig, rect) + self.cbar_axes.append(cax) + + self.axes_llc = self.axes_column[0][-1] + + self._update_locators() + + if add_all: + for ax in self.axes_all+self.cbar_axes: + fig.add_axes(ax) + + self.set_label_mode(label_mode) + + + def _update_locators(self): + + h = [] + + h_ax_pos = [] + h_cb_pos = [] + for ax in self._column_refax: + if h: h.append(Size.Fixed(self._axes_pad)) + + h_ax_pos.append(len(h)) + + if ax: + sz = Size.AxesX(ax) + else: + sz = Size.AxesX(self.axes_llc) + h.append(sz) + + if self._colorbar_mode == "each" and self._colorbar_location == "right": + h.append(Size.from_any(self._colorbar_pad, sz)) + h_cb_pos.append(len(h)) + h.append(Size.from_any(self._colorbar_size, sz)) + + + v = [] + + v_ax_pos = [] + v_cb_pos = [] + for ax in self._row_refax[::-1]: + if v: v.append(Size.Fixed(self._axes_pad)) + v_ax_pos.append(len(v)) + if ax: + sz = Size.AxesY(ax) + else: + sz = Size.AxesY(self.axes_llc) + v.append(sz) + + + if self._colorbar_mode == "each" and self._colorbar_location == "top": + v.append(Size.from_any(self._colorbar_pad, sz)) + v_cb_pos.append(len(v)) + v.append(Size.from_any(self._colorbar_size, sz)) + + + for i in range(self.ngrids): + col, row = self.get_col_row(i) + #locator = self._divider.new_locator(nx=4*col, ny=2*(self._nrows - row - 1)) + locator = self._divider.new_locator(nx=h_ax_pos[col], + ny=v_ax_pos[self._nrows -1 - row]) + self.axes_all[i].set_axes_locator(locator) + + if self._colorbar_mode == "each": + if self._colorbar_location == "right": + locator = self._divider.new_locator(nx=h_cb_pos[col], + ny=v_ax_pos[self._nrows -1 - row]) + elif self._colorbar_location == "top": + locator = self._divider.new_locator(nx=h_ax_pos[col], + ny=v_cb_pos[self._nrows -1 - row]) + self.cbar_axes[i].set_axes_locator(locator) + + + if self._colorbar_mode == "single": + if self._colorbar_location == "right": + sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) + h.append(Size.from_any(self._colorbar_pad, sz)) + h.append(Size.from_any(self._colorbar_size, sz)) + locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1) + elif self._colorbar_location == "top": + sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) + v.append(Size.from_any(self._colorbar_pad, sz)) + v.append(Size.from_any(self._colorbar_size, sz)) + locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2) + for i in range(self.ngrids): + self.cbar_axes[i].set_visible(False) + self.cbar_axes[0].set_axes_locator(locator) + self.cbar_axes[0].set_visible(True) + elif self._colorbar_mode == "each": + for i in range(self.ngrids): + self.cbar_axes[i].set_visible(True) + else: + for i in range(self.ngrids): + self.cbar_axes[i].set_visible(False) + + self._divider.set_horizontal(h) + self._divider.set_vertical(v) + + + + def get_col_row(self, n): + if self._direction == "column": + col, row = divmod(n, self._nrows) + else: + row, col = divmod(n, self._ncols) + + return col, row + + + def __getitem__(self, i): + return self.axes_all[i] + + + def get_geometry(self): + return self._nrows, self._ncols + + def set_axes_pad(self, axes_pad): + self._axes_pad = axes_pad + + def get_axes_pad(self): + return self._axes_pad + + def set_aspect(self, aspect): + self._divider.set_aspect(aspect) + + def get_aspect(self): + return self._divider.get_aspect() + + def set_label_mode(self, mode): + if mode == "all": + for ax in self.axes_all: + [l.set_visible(True) for l in ax.get_xticklabels()] + [l.set_visible(True) for l in ax.get_yticklabels()] + elif mode == "L": + for ax in self.axes_column[0][:-1]: + [l.set_visible(False) for l in ax.get_xticklabels()] + [l.set_visible(True) for l in ax.get_yticklabels()] + ax = self.axes_column[0][-1] + [l.set_visible(True) for l in ax.get_xticklabels()] + [l.set_visible(True) for l in ax.get_yticklabels()] + for col in self.axes_column[1:]: + for ax in col[:-1]: + [l.set_visible(False) for l in ax.get_xticklabels()] + [l.set_visible(False) for l in ax.get_yticklabels()] + ax = col[-1] + [l.set_visible(True) for l in ax.get_xticklabels()] + [l.set_visible(False) for l in ax.get_yticklabels()] + elif mode == "1": + for ax in self.axes_all: + [l.set_visible(False) for l in ax.get_xticklabels()] + [l.set_visible(False) for l in ax.get_yticklabels()] + ax = self.axes_llc + [l.set_visible(True) for l in ax.get_xticklabels()] + [l.set_visible(True) for l in ax.get_yticklabels()] + + + +if __name__ == "__main__": + F = plt.figure(1, (9, 3.5)) + F.clf() + + F.subplots_adjust(left=0.05, right=0.98) + + grid = AxesGrid(F, 131, # similar to subplot(111) + nrows_ncols = (2, 2), + direction="row", + axes_pad = 0.05, + add_all=True, + label_mode = "1", + ) + + Z, extent = get_demo_image() + plt.ioff() + for i in range(4): + im = grid[i].imshow(Z, extent=extent, interpolation="nearest") + + # This only affects axes in first column and second row as share_all = False. + grid.axes_llc.set_xticks([-2, 0, 2]) + grid.axes_llc.set_yticks([-2, 0, 2]) + plt.ion() + + + grid = AxesGrid(F, 132, # similar to subplot(111) + nrows_ncols = (2, 2), + direction="row", + axes_pad = 0.0, + add_all=True, + share_all=True, + label_mode = "1", + colorbar_mode="single", + ) + + Z, extent = get_demo_image() + plt.ioff() + for i in range(4): + im = grid[i].imshow(Z, extent=extent, interpolation="nearest") + plt.colorbar(im, cax = grid.cbar_axes[0]) + plt.setp(grid.cbar_axes[0].get_yticklabels(), visible=False) + + # This affects all axes as share_all = True. + grid.axes_llc.set_xticks([-2, 0, 2]) + grid.axes_llc.set_yticks([-2, 0, 2]) + + plt.ion() + + + + grid = AxesGrid(F, 133, # similar to subplot(122) + nrows_ncols = (2, 2), + direction="row", + axes_pad = 0.1, + add_all=True, + label_mode = "1", + share_all = True, + colorbar_location="top", + colorbar_mode="each", + colorbar_size="7%", + colorbar_pad="2%", + ) + plt.ioff() + for i in range(4): + im = grid[i].imshow(Z, extent=extent, interpolation="nearest") + plt.colorbar(im, cax = grid.cbar_axes[i], + orientation="horizontal") + grid.cbar_axes[i].xaxis.set_ticks_position("top") + plt.setp(grid.cbar_axes[i].get_xticklabels(), visible=False) + + # This affects all axes as share_all = True. + grid.axes_llc.set_xticks([-2, 0, 2]) + grid.axes_llc.set_yticks([-2, 0, 2]) + + plt.ion() + plt.draw() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年12月19日 21:41:11 UTC (rev 6686) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年12月19日 22:48:11 UTC (rev 6687) @@ -545,6 +545,8 @@ self.set_navigate(True) self.set_navigate_mode(None) + self._axes_locator = None + if len(kwargs): martist.setp(self, **kwargs) if self.xaxis is not None: @@ -793,6 +795,21 @@ pos = self.get_position(original=True) self.set_position(pos, which='active') + def set_axes_locator(self, locator): + """ + set axes_locator + + ACCEPT : a callable object which takes an axes instance and renderer and + returns a bbox. + """ + self._axes_locator = locator + + def get_axes_locator(self): + """ + return axes_locator + """ + return self._axes_locator + def _set_artist_props(self, a): 'set the boilerplate props for artists added to axes' a.set_figure(self.figure) @@ -1531,7 +1548,12 @@ if not self.get_visible(): return renderer.open_group('axes') - self.apply_aspect() + locator = self.get_axes_locator() + if locator: + pos = locator(self, renderer) + self.apply_aspect(pos) + else: + self.apply_aspect() # the patch draws the background rectangle -- the frame below # will draw the edges This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6686 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6686&view=rev Author: leejjoon Date: 2008年12月19日 21:41:11 +0000 (2008年12月19日) Log Message: ----------- Merged revisions 6685 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6685 | leejjoon | 2008年12月19日 16:24:32 -0500 (2008年12月19日) | 1 line update legend-related document ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/doc/api/api_changes.rst trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template trunk/matplotlib/lib/matplotlib/rcsetup.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6681 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6685 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/CHANGELOG 2008年12月19日 21:41:11 UTC (rev 6686) @@ -1,3 +1,7 @@ +2008年12月19日 Update Axes.legend documnetation. /api/api_changes.rst is also + updated to describe chages in keyword parameters. + Issue a warning if old keyword parameters are used. - JJL + 2008年12月18日 add new arrow style, a line + filled triangles. -JJL ================================================================== Modified: trunk/matplotlib/doc/api/api_changes.rst =================================================================== --- trunk/matplotlib/doc/api/api_changes.rst 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/doc/api/api_changes.rst 2008年12月19日 21:41:11 UTC (rev 6686) @@ -15,6 +15,22 @@ Changes for 0.98.x ================== +* Following keyword parameters for :class:`matplotlib.label.Label` are now + deprecated and new set of parameters are introduced. The new parameters + are given as a fraction of the font-size. Also, *scatteryoffsets*, + *fancybox* and *columnspacing* are added as keyword parameters. + + ================ ================ + Deprecated New + ================ ================ + pad borderpad + labelsep labelspacing + handlelen handlelength + handlestextsep handletextpad + axespad borderaxespad + ================ ================ + + * Removed the configobj and experiemtnal traits rc support * Modified :func:`matplotlib.mlab.psd`, :func:`matplotlib.mlab.csd`, Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008年12月19日 21:41:11 UTC (rev 6686) @@ -582,7 +582,15 @@ 'tick.size' : 'tick.major.size', } +_deprecated_ignore_map = { + 'legend.pad' : 'legend.borderpad', + 'legend.labelsep' : 'legend.labelspacing', + 'legend.handlelen' : 'legend.handlelength', + 'legend.handletextsep' : 'legend.handletextpad', + 'legend.axespad' : 'legend.borderaxespad', + } + class RcParams(dict): """ @@ -602,6 +610,10 @@ warnings.warn('%s is deprecated in matplotlibrc. Use %s \ instead.'% (key, alt)) key = alt + elif key in _deprecated_ignore_map: + alt = _deprecated_ignore_map[key] + warnings.warn('%s is deprecated. Use %s instead.'% (key, alt)) + return cval = self.validate[key](val) dict.__setitem__(self, key, cval) except KeyError: @@ -665,6 +677,9 @@ except Exception, msg: warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file \ "%s"\n\t%s' % (val, cnt, line, fname, msg)) + elif key in _deprecated_ignore_map: + warnings.warn('%s is deprecated. Update your matplotlibrc to use %s instead.'% (key, _deprecated_ignore_map[key])) + else: print >> sys.stderr, """ Bad key "%s" on line %d in Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年12月19日 21:41:11 UTC (rev 6686) @@ -3740,10 +3740,6 @@ A :class:`matplotlib.font_manager.FontProperties` instance, or *None* to use rc settings. - *pad*: [ None | scalar ] - The fractional whitespace inside the legend border, between 0 and 1. - If *None*, use rc settings. - *markerscale*: [ None | scalar ] The relative size of legend markers vs. original. If *None*, use rc settings. @@ -3751,21 +3747,21 @@ *shadow*: [ None | False | True ] If *True*, draw a shadow behind legend. If *None*, use rc settings. - *labelsep*: [ None | scalar ] - The vertical space between the legend entries. If *None*, use rc - settings. + Padding and spacing between various elements use following keywords + parameters. The dimensions of these values are given as a fraction + of the fontsize. Values from rcParams will be used if None. - *handlelen*: [ None | scalar ] - The length of the legend lines. If *None*, use rc settings. + ================ ================================================================== + Keyword Description + ================ ================================================================== + borderpad the fractional whitespace inside the legend border + labelspacing the vertical space between the legend entries + handlelength the length of the legend handles + handletextpad the pad between the legend handle and text + borderaxespad the pad between the axes and legend border + columnspacing the spacing between columns + ================ ================================================================== - *handletextsep*: [ None | scalar ] - The space between the legend line and legend text. If *None*, use rc - settings. - - *axespad*: [ None | scalar ] - The border between the axes and legend edge. If *None*, use rc - settings. - **Example:** .. plot:: mpl_examples/api/legend_demo.py Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008年12月19日 21:41:11 UTC (rev 6686) @@ -98,7 +98,7 @@ handletextsep = None, # deprecated; use handletextpad axespad = None, # deprecated; use borderaxespad - # spacing & pad defined as a fractionof the font-size + # spacing & pad defined as a fraction of the font-size borderpad = None, # the whitespace inside the legend border labelspacing=None, #the vertical space between the legend entries handlelength=None, # the length of the legend handles Modified: trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template =================================================================== --- trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/lib/matplotlib/mpl-data/matplotlib.conf.template 2008年12月19日 21:41:11 UTC (rev 6686) @@ -233,19 +233,11 @@ origin = 'upper' [legend] - # a float - axespad = 0.02 # a float or 'xx-small' or 'x-small' or 'small' or 'medium' or 'large' or # 'x-large' or 'xx-large' fontsize = 'medium' - # a float - handlelen = 0.050000000000000003 - # a float - handletextsep = 0.02 # a boolean isaxes = True - # a float - labelsep = 0.01 # 'best' or 'upper right' or 'upper left' or 'lower left' or 'lower right' # or 'right' or 'center left' or 'center right' or 'lower center' or # 'upper center' or 'center' @@ -254,11 +246,22 @@ markerscale = 1.0 # an integer numpoints = 3 - # a float - pad = 0.20000000000000001 # a boolean shadow = False + # float + borderpad = 0.4 + # float + labelspacing = 0.5 + # float + handlelength = 2. + # float + handletextpad = 0.8 + # float + borderaxespad = 0.5 + # float + columnspacing = 2. + [lines] # a boolean antialiased = True Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008年12月19日 21:24:32 UTC (rev 6685) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008年12月19日 21:41:11 UTC (rev 6686) @@ -432,18 +432,12 @@ 'legend.isaxes' : [True,validate_bool], # this option is internally ignored - it never served any useful purpose 'legend.numpoints' : [2, validate_int], # the number of points in the legend line 'legend.fontsize' : ['large', validate_fontsize], - 'legend.pad' : [0, validate_float], # was 0.2, deprecated; the fractional whitespace inside the legend border - 'legend.borderpad' : [0.4, validate_float], # units are fontsize 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original - - # the following dimensions are in axes coords - 'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries - 'legend.handlelen' : [0.05, validate_float], # the length of the legend lines - 'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text - 'legend.axespad' : [0.02, validate_float], # the border between the axes and legend edge 'legend.shadow' : [False, validate_bool], + # the following dimensions are in fraction of the font size + 'legend.borderpad' : [0.4, validate_float], # units are fontsize 'legend.labelspacing' : [0.5, validate_float], # the vertical space between the legend entries 'legend.handlelength' : [2., validate_float], # the length of the legend lines 'legend.handletextpad' : [.8, validate_float], # the space between the legend line and legend text @@ -453,11 +447,6 @@ 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original - # the following dimensions are in axes coords - 'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries - 'legend.handlelen' : [0.05, validate_float], # the length of the legend lines - 'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text - 'legend.axespad' : [0.5, validate_float], # the border between the axes and legend edge 'legend.shadow' : [False, validate_bool], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6685&view=rev Author: leejjoon Date: 2008年12月19日 21:24:32 +0000 (2008年12月19日) Log Message: ----------- update legend-related document Modified Paths: -------------- branches/v0_98_5_maint/CHANGELOG branches/v0_98_5_maint/doc/api/api_changes.rst branches/v0_98_5_maint/lib/matplotlib/__init__.py branches/v0_98_5_maint/lib/matplotlib/axes.py branches/v0_98_5_maint/lib/matplotlib/legend.py branches/v0_98_5_maint/lib/matplotlib/mpl-data/matplotlib.conf.template branches/v0_98_5_maint/lib/matplotlib/rcsetup.py Modified: branches/v0_98_5_maint/CHANGELOG =================================================================== --- branches/v0_98_5_maint/CHANGELOG 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/CHANGELOG 2008年12月19日 21:24:32 UTC (rev 6685) @@ -1,3 +1,6 @@ +2008年12月19日 Update Axes.legend documnetation. /api/api_changes.rst is also + updated to describe chages in keyword parameters. + Issue a warning if old keyword parameters are used. - JJL ======================================================================= Re-Released 0.98.5.2 at r6679 Modified: branches/v0_98_5_maint/doc/api/api_changes.rst =================================================================== --- branches/v0_98_5_maint/doc/api/api_changes.rst 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/doc/api/api_changes.rst 2008年12月19日 21:24:32 UTC (rev 6685) @@ -8,6 +8,22 @@ Changes for 0.98.x ================== +* Following keyword parameters for :class:`matplotlib.label.Label` are now + deprecated and new set of parameters are introduced. The new parameters + are given as a fraction of the font-size. Also, *scatteryoffsets*, + *fancybox* and *columnspacing* are added as keyword parameters. + + ================ ================ + Deprecated New + ================ ================ + pad borderpad + labelsep labelspacing + handlelen handlelength + handlestextsep handletextpad + axespad borderaxespad + ================ ================ + + * Removed the configobj and experiemtnal traits rc support * Modified :func:`matplotlib.mlab.psd`, :func:`matplotlib.mlab.csd`, Modified: branches/v0_98_5_maint/lib/matplotlib/__init__.py =================================================================== --- branches/v0_98_5_maint/lib/matplotlib/__init__.py 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/lib/matplotlib/__init__.py 2008年12月19日 21:24:32 UTC (rev 6685) @@ -582,7 +582,15 @@ 'tick.size' : 'tick.major.size', } +_deprecated_ignore_map = { + 'legend.pad' : 'legend.borderpad', + 'legend.labelsep' : 'legend.labelspacing', + 'legend.handlelen' : 'legend.handlelength', + 'legend.handletextsep' : 'legend.handletextpad', + 'legend.axespad' : 'legend.borderaxespad', + } + class RcParams(dict): """ @@ -602,6 +610,10 @@ warnings.warn('%s is deprecated in matplotlibrc. Use %s \ instead.'% (key, alt)) key = alt + elif key in _deprecated_ignore_map: + alt = _deprecated_ignore_map[key] + warnings.warn('%s is deprecated. Use %s instead.'% (key, alt)) + return cval = self.validate[key](val) dict.__setitem__(self, key, cval) except KeyError: @@ -665,6 +677,9 @@ except Exception, msg: warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file \ "%s"\n\t%s' % (val, cnt, line, fname, msg)) + elif key in _deprecated_ignore_map: + warnings.warn('%s is deprecated. Update your matplotlibrc to use %s instead.'% (key, _deprecated_ignore_map[key])) + else: print >> sys.stderr, """ Bad key "%s" on line %d in Modified: branches/v0_98_5_maint/lib/matplotlib/axes.py =================================================================== --- branches/v0_98_5_maint/lib/matplotlib/axes.py 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/lib/matplotlib/axes.py 2008年12月19日 21:24:32 UTC (rev 6685) @@ -3728,10 +3728,6 @@ A :class:`matplotlib.font_manager.FontProperties` instance, or *None* to use rc settings. - *pad*: [ None | scalar ] - The fractional whitespace inside the legend border, between 0 and 1. - If *None*, use rc settings. - *markerscale*: [ None | scalar ] The relative size of legend markers vs. original. If *None*, use rc settings. @@ -3739,21 +3735,21 @@ *shadow*: [ None | False | True ] If *True*, draw a shadow behind legend. If *None*, use rc settings. - *labelsep*: [ None | scalar ] - The vertical space between the legend entries. If *None*, use rc - settings. + Padding and spacing between various elements use following keywords + parameters. The dimensions of these values are given as a fraction + of the fontsize. Values from rcParams will be used if None. - *handlelen*: [ None | scalar ] - The length of the legend lines. If *None*, use rc settings. + ================ ================================================================== + Keyword Description + ================ ================================================================== + borderpad the fractional whitespace inside the legend border + labelspacing the vertical space between the legend entries + handlelength the length of the legend handles + handletextpad the pad between the legend handle and text + borderaxespad the pad between the axes and legend border + columnspacing the spacing between columns + ================ ================================================================== - *handletextsep*: [ None | scalar ] - The space between the legend line and legend text. If *None*, use rc - settings. - - *axespad*: [ None | scalar ] - The border between the axes and legend edge. If *None*, use rc - settings. - **Example:** .. plot:: mpl_examples/api/legend_demo.py Modified: branches/v0_98_5_maint/lib/matplotlib/legend.py =================================================================== --- branches/v0_98_5_maint/lib/matplotlib/legend.py 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/lib/matplotlib/legend.py 2008年12月19日 21:24:32 UTC (rev 6685) @@ -98,7 +98,7 @@ handletextsep = None, # deprecated; use handletextpad axespad = None, # deprecated; use borderaxespad - # spacing & pad defined as a fractionof the font-size + # spacing & pad defined as a fraction of the font-size borderpad = None, # the whitespace inside the legend border labelspacing=None, #the vertical space between the legend entries handlelength=None, # the length of the legend handles Modified: branches/v0_98_5_maint/lib/matplotlib/mpl-data/matplotlib.conf.template =================================================================== --- branches/v0_98_5_maint/lib/matplotlib/mpl-data/matplotlib.conf.template 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/lib/matplotlib/mpl-data/matplotlib.conf.template 2008年12月19日 21:24:32 UTC (rev 6685) @@ -233,19 +233,11 @@ origin = 'upper' [legend] - # a float - axespad = 0.02 # a float or 'xx-small' or 'x-small' or 'small' or 'medium' or 'large' or # 'x-large' or 'xx-large' fontsize = 'medium' - # a float - handlelen = 0.050000000000000003 - # a float - handletextsep = 0.02 # a boolean isaxes = True - # a float - labelsep = 0.01 # 'best' or 'upper right' or 'upper left' or 'lower left' or 'lower right' # or 'right' or 'center left' or 'center right' or 'lower center' or # 'upper center' or 'center' @@ -254,11 +246,22 @@ markerscale = 1.0 # an integer numpoints = 3 - # a float - pad = 0.20000000000000001 # a boolean shadow = False + # float + borderpad = 0.4 + # float + labelspacing = 0.5 + # float + handlelength = 2. + # float + handletextpad = 0.8 + # float + borderaxespad = 0.5 + # float + columnspacing = 2. + [lines] # a boolean antialiased = True Modified: branches/v0_98_5_maint/lib/matplotlib/rcsetup.py =================================================================== --- branches/v0_98_5_maint/lib/matplotlib/rcsetup.py 2008年12月19日 20:27:18 UTC (rev 6684) +++ branches/v0_98_5_maint/lib/matplotlib/rcsetup.py 2008年12月19日 21:24:32 UTC (rev 6685) @@ -422,18 +422,12 @@ 'legend.isaxes' : [True,validate_bool], # this option is internally ignored - it never served any useful purpose 'legend.numpoints' : [2, validate_int], # the number of points in the legend line 'legend.fontsize' : ['large', validate_fontsize], - 'legend.pad' : [0, validate_float], # was 0.2, deprecated; the fractional whitespace inside the legend border - 'legend.borderpad' : [0.4, validate_float], # units are fontsize 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original - - # the following dimensions are in axes coords - 'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries - 'legend.handlelen' : [0.05, validate_float], # the length of the legend lines - 'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text - 'legend.axespad' : [0.02, validate_float], # the border between the axes and legend edge 'legend.shadow' : [False, validate_bool], + # the following dimensions are in fraction of the font size + 'legend.borderpad' : [0.4, validate_float], # units are fontsize 'legend.labelspacing' : [0.5, validate_float], # the vertical space between the legend entries 'legend.handlelength' : [2., validate_float], # the length of the legend lines 'legend.handletextpad' : [.8, validate_float], # the space between the legend line and legend text @@ -443,11 +437,6 @@ 'legend.markerscale' : [1.0, validate_float], # the relative size of legend markers vs. original - # the following dimensions are in axes coords - 'legend.labelsep' : [0.010, validate_float], # the vertical space between the legend entries - 'legend.handlelen' : [0.05, validate_float], # the length of the legend lines - 'legend.handletextsep' : [0.02, validate_float], # the space between the legend line and legend text - 'legend.axespad' : [0.5, validate_float], # the border between the axes and legend edge 'legend.shadow' : [False, validate_bool], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6684 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6684&view=rev Author: jdh2358 Date: 2008年12月19日 20:27:18 +0000 (2008年12月19日) Log Message: ----------- added ringbuf license Modified Paths: -------------- trunk/py4science/examples/pyrex/trailstats/ringbuf.h trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx trunk/py4science/examples/pyrex/trailstats/ringbufnan.c Added Paths: ----------- trunk/py4science/examples/pyrex/trailstats/LICENSE.ringbuf Added: trunk/py4science/examples/pyrex/trailstats/LICENSE.ringbuf =================================================================== --- trunk/py4science/examples/pyrex/trailstats/LICENSE.ringbuf (rev 0) +++ trunk/py4science/examples/pyrex/trailstats/LICENSE.ringbuf 2008年12月19日 20:27:18 UTC (rev 6684) @@ -0,0 +1,32 @@ +Copyright (c) 2008, Eric Firing +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the copyright holder nor the names of + subsequent contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + Modified: trunk/py4science/examples/pyrex/trailstats/ringbuf.h =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbuf.h 2008年12月19日 19:31:23 UTC (rev 6683) +++ trunk/py4science/examples/pyrex/trailstats/ringbuf.h 2008年12月19日 20:27:18 UTC (rev 6684) @@ -1,5 +1,5 @@ +//See LICENSE.ringbuf for license (BSD) - typedef struct { int N_size; int N_filled; Modified: trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx 2008年12月19日 19:31:23 UTC (rev 6683) +++ trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx 2008年12月19日 20:27:18 UTC (rev 6684) @@ -3,6 +3,8 @@ Ringbuf, on which various statistics are calculated as each entry is added and a method runstats for computing a host of trailing statistics over a numpy array + +See LICENSE.ringbuf for license (BSD) """ include "c_ringbuf.pxi" Modified: trunk/py4science/examples/pyrex/trailstats/ringbufnan.c =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbufnan.c 2008年12月19日 19:31:23 UTC (rev 6683) +++ trunk/py4science/examples/pyrex/trailstats/ringbufnan.c 2008年12月19日 20:27:18 UTC (rev 6684) @@ -10,6 +10,7 @@ 2003年07月28日 EF +See LICENSE.ringbuf for license (BSD) */ #include <stdlib.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6683 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6683&view=rev Author: jdh2358 Date: 2008年12月19日 19:31:23 +0000 (2008年12月19日) Log Message: ----------- fixed a min/max bug when initial values all nan Modified Paths: -------------- trunk/py4science/examples/pyrex/trailstats/c_ringbuf.pxi trunk/py4science/examples/pyrex/trailstats/movavg_fast.py trunk/py4science/examples/pyrex/trailstats/ringbuf.h trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx trunk/py4science/examples/pyrex/trailstats/ringbufnan.c trunk/py4science/examples/pyrex/trailstats/setup.py Modified: trunk/py4science/examples/pyrex/trailstats/c_ringbuf.pxi =================================================================== --- trunk/py4science/examples/pyrex/trailstats/c_ringbuf.pxi 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/c_ringbuf.pxi 2008年12月19日 19:31:23 UTC (rev 6683) @@ -18,6 +18,7 @@ double ringbuf_min(ringbuf_t *rb_ptr) double ringbuf_max(ringbuf_t *rb_ptr) double ringbuf_median(ringbuf_t *rb_ptr) + double ringbuf_ptile(ringbuf_t *rb_ptr, double x) int ringbuf_N_good(ringbuf_t *rb_ptr) int ringbuf_N_added(ringbuf_t *rb_ptr) int ringbuf_N_filled(ringbuf_t *rb_ptr) @@ -28,8 +29,12 @@ double *dstd, double *dmin, double *dmax, - double *dmed, int *ng) + double *dmed, + double *dptile5, + double *dptile95, + int *ng) void c_runstats2(int nrb, int nd, int step, int ofs, double *data, double *dmean, double *dstd, - double *dmin, double *dmax, double *dmed, int *ng) + double *dmin, double *dmax, double *dmed, double *dptile5, + double *dptile95, int *ng) Modified: trunk/py4science/examples/pyrex/trailstats/movavg_fast.py =================================================================== --- trunk/py4science/examples/pyrex/trailstats/movavg_fast.py 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/movavg_fast.py 2008年12月19日 19:31:23 UTC (rev 6683) @@ -5,10 +5,10 @@ import ringbuf x = numpy.random.rand(10000) -dmean, dstd, dmin, dmax, dmedian, ng = ringbuf.runstats(x, 30) +dmean, dstd, dmin, dmax, dmedian, ptile5, ptile95, ng = ringbuf.runstats(x, 30) r = numpy.rec.fromarrays([dmean, dstd, dmin, dmax, dmedian, ng], - names='dmean,dstd,dmin,dmax,dmedian,ngood') + names='dmean,dstd,dmin,dmax,dmedian,ptile5,ptile95,ngood') Modified: trunk/py4science/examples/pyrex/trailstats/ringbuf.h =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbuf.h 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/ringbuf.h 2008年12月19日 19:31:23 UTC (rev 6683) @@ -25,6 +25,7 @@ double ringbuf_min(ringbuf_t *rb_ptr); double ringbuf_max(ringbuf_t *rb_ptr); double ringbuf_median(ringbuf_t *rb_ptr); +double ringbuf_ptile(ringbuf_t *rb_ptr, double val); int ringbuf_N_added(ringbuf_t *rb_ptr); int ringbuf_N_filled(ringbuf_t *rb_ptr); int ringbuf_N_good(ringbuf_t *rb_ptr); @@ -32,10 +33,10 @@ double ringbuf_sd(ringbuf_t *rb_ptr); void c_runstats(int nrb, int nd, double *data, double *dmean, double *dstd, - double *dmin, double *dmax, double *dmed, int *ng); + double *dmin, double *dmax, double *dmed, double *dptile5, double *dptile95, int *ng); void c_runstats2(int nrb, int nd, int step, int ofs, double *data, double *dmean, double *dstd, - double *dmin, double *dmax, double *dmed, int *ng); + double *dmin, double *dmax, double *dmed, double *dptile5, double *dptile95, int *ng); Modified: trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/ringbuf.pyx 2008年12月19日 19:31:23 UTC (rev 6683) @@ -14,7 +14,7 @@ cdef class Ringbuf: cdef ringbuf_t *rb_ptr - def __new__(self, N): + def __cinit__(self, N): self.rb_ptr = new_ringbuf(N) def __dealloc__(self): @@ -55,6 +55,9 @@ def median(self): return ringbuf_median(self.rb_ptr) + def ptile(self, x): + return ringbuf_ptile(self.rb_ptr, x) + def N_added(self): return ringbuf_N_added(self.rb_ptr) @@ -73,7 +76,7 @@ cdef object records - def __new__(self, N): + def __cinit__(self, N): self.rb_ptr = new_ringbuf(N) self.records = [] @@ -122,6 +125,9 @@ def median(self): return ringbuf_median(self.rb_ptr) + def ptile(self, x): + return ringbuf_ptile(self.rb_ptr, x) + def N_added(self): return ringbuf_N_added(self.rb_ptr) @@ -160,6 +166,8 @@ cdef c_numpy.ndarray c_dmin cdef c_numpy.ndarray c_dmax cdef c_numpy.ndarray c_dmedian + cdef c_numpy.ndarray c_dptile5 + cdef c_numpy.ndarray c_dptile95 cdef c_numpy.ndarray c_ng # make sure that the input array is a 1D numpy array of floats. @@ -181,6 +189,8 @@ dmin = numpy.empty_like(data) dmax = numpy.empty_like(data) dmedian = numpy.empty_like(data) + dptile5 = numpy.empty_like(data) + dptile95 = numpy.empty_like(data) ng = numpy.empty(data.shape, dtype=numpy.int_) # now we have to assign the c_data structures and friends to their @@ -191,6 +201,8 @@ c_dmin = dmin c_dmax = dmax c_dmedian = dmedian + c_dptile5 = dptile5 + c_dptile95 = dptile95 c_ng = ng # now we call the function and pass in the c data pointers to the @@ -202,7 +214,9 @@ <double *>c_dmin.data, <double *>c_dmax.data, <double *>c_dmedian.data, + <double *>c_dptile5.data, + <double *>c_dptile95.data, <int *>c_ng.data) # all done, return the arrays - return dmean, dstd, dmin, dmax, dmedian, ng + return dmean, dstd, dmin, dmax, dmedian, dptile5, dptile95, ng Modified: trunk/py4science/examples/pyrex/trailstats/ringbufnan.c =================================================================== --- trunk/py4science/examples/pyrex/trailstats/ringbufnan.c 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/ringbufnan.c 2008年12月19日 19:31:23 UTC (rev 6683) @@ -121,7 +121,7 @@ d_old = rb_ptr->data[rb_ptr->i_oldest]; rb_ptr->data[i_new] = d; good_new = !isnan(d); -#if 0 +#if 1 printf("new value: %lf good_new: %d\n", d, good_new); printf("i_next: %d i_oldest: %d N_filled: %d N_good: %d\n", rb_ptr->i_next, rb_ptr->i_oldest, @@ -183,7 +183,7 @@ { resum_ringbuf(rb_ptr); } -#if 0 +#if 1 printf("i_next: %d i_oldest: %d N_filled: %d N_good: %d\n", rb_ptr->i_next, rb_ptr->i_oldest, rb_ptr->N_filled, rb_ptr->N_good); @@ -221,13 +221,21 @@ double ringbuf_min(ringbuf_t *rb_ptr) { + if (rb_ptr->N_good==0) + return NaN; return rb_ptr->data[rb_ptr->i_sorted[0]]; } double ringbuf_max(ringbuf_t *rb_ptr) { - int i_end; + + int i_end; + + if (rb_ptr->N_good==0) + return NaN; + i_end = rb_ptr->N_good - 1; + return rb_ptr->data[rb_ptr->i_sorted[i_end]]; } @@ -248,6 +256,16 @@ } } +double ringbuf_ptile(ringbuf_t *rb_ptr, double ptile) +{ + int i, N; + + N = rb_ptr->N_good; + if (N == 0) return NaN; + i = (int)(ptile*N); + return rb_ptr->data[rb_ptr->i_sorted[i]]; +} + int ringbuf_N_good(ringbuf_t *rb_ptr) { return rb_ptr->N_good; @@ -272,6 +290,7 @@ { int N; + N = rb_ptr->N_good; if (N > 0) { @@ -286,6 +305,7 @@ double ringbuf_sd(ringbuf_t *rb_ptr) { double m, s; + int N; N = rb_ptr->N_good; @@ -304,7 +324,7 @@ } void c_runstats(int nrb, int nd, double *data, double *dmean, double *dstd, - double *dmin, double *dmax, double *dmed, int *ng) + double *dmin, double *dmax, double *dmed, double *dptile5, double *dptile95, int *ng) { int i, j; ringbuf_t *rb_ptr; @@ -319,6 +339,8 @@ dmin[j] = ringbuf_min(rb_ptr); dmax[j] = ringbuf_max(rb_ptr); dmed[j] = ringbuf_median(rb_ptr); + dptile5[j] = ringbuf_ptile(rb_ptr, 0.05); + dptile95[j] = ringbuf_ptile(rb_ptr, 0.95); ng[j] = rb_ptr->N_good; } delete_ringbuf(rb_ptr); @@ -327,7 +349,8 @@ void c_runstats2(int nrb, int nd, int step, int ofs, double *data, double *dmean, double *dstd, - double *dmin, double *dmax, double *dmed, int *ng) + double *dmin, double *dmax, double *dmed, double +*dptile5, double *dptile95, int *ng) { int i, j; int npad = (nrb - 1) / 2; @@ -339,6 +362,8 @@ dmin += ofs; dmax += ofs; dmed += ofs; + dptile5 += ofs; + dptile95 += ofs; ng += ofs; rb_ptr = new_ringbuf(nrb); @@ -355,6 +380,8 @@ dmin[j*step] = ringbuf_min(rb_ptr); dmax[j*step] = ringbuf_max(rb_ptr); dmed[j*step] = ringbuf_median(rb_ptr); + dptile5[j*step] = ringbuf_ptile(rb_ptr, 0.05); + dptile95[j*step] = ringbuf_ptile(rb_ptr, 0.95); ng[j*step] = rb_ptr->N_good; } delete_ringbuf(rb_ptr); Modified: trunk/py4science/examples/pyrex/trailstats/setup.py =================================================================== --- trunk/py4science/examples/pyrex/trailstats/setup.py 2008年12月19日 12:40:09 UTC (rev 6682) +++ trunk/py4science/examples/pyrex/trailstats/setup.py 2008年12月19日 19:31:23 UTC (rev 6683) @@ -4,11 +4,8 @@ # Make this usable by people who don't have pyrex installed (I've committed # the generated C sources to SVN). -try: - from Pyrex.Distutils import build_ext - has_pyrex = True -except ImportError: - has_pyrex = False +from Cython.Distutils import build_ext +has_pyrex = True import numpy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6682 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6682&view=rev Author: jdh2358 Date: 2008年12月19日 12:40:09 +0000 (2008年12月19日) Log Message: ----------- Merged revisions 6679-6680 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6679 | jdh2358 | 2008年12月19日 06:29:49 -0600 (2008年12月19日) | 1 line added macosx.m to manifest ........ r6680 | jdh2358 | 2008年12月19日 06:30:33 -0600 (2008年12月19日) | 1 line added macosx.m to manifest; released 98.5.2 tarball ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/MANIFEST.in Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6676 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6681 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年12月19日 12:38:33 UTC (rev 6681) +++ trunk/matplotlib/CHANGELOG 2008年12月19日 12:40:09 UTC (rev 6682) @@ -1,7 +1,7 @@ 2008年12月18日 add new arrow style, a line + filled triangles. -JJL ================================================================== -2008年12月18日 Re-Released 0.98.5.2 from v0_98_5_maint at r6675 +2008年12月18日 Re-Released 0.98.5.2 from v0_98_5_maint at r6679 Released 0.98.5.2 from v0_98_5_maint at r6667 2008年12月18日 Removed configobj, experimental traits and doc/mpl_data link - JDH Modified: trunk/matplotlib/MANIFEST.in =================================================================== --- trunk/matplotlib/MANIFEST.in 2008年12月19日 12:38:33 UTC (rev 6681) +++ trunk/matplotlib/MANIFEST.in 2008年12月19日 12:40:09 UTC (rev 6682) @@ -16,7 +16,7 @@ recursive-include license LICENSE* recursive-include examples * recursive-include doc * -recursive-include src *.cpp *.c *.h +recursive-include src *.cpp *.c *.h *.m recursive-include CXX *.cxx *.hxx *.c *.h recursive-include agg24 * recursive-include lib * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6681 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6681&view=rev Author: jdh2358 Date: 2008年12月19日 12:38:33 +0000 (2008年12月19日) Log Message: ----------- minor tweaks to makefile for osx release Modified Paths: -------------- trunk/matplotlib/release/osx/Makefile Modified: trunk/matplotlib/release/osx/Makefile =================================================================== --- trunk/matplotlib/release/osx/Makefile 2008年12月19日 12:30:33 UTC (rev 6680) +++ trunk/matplotlib/release/osx/Makefile 2008年12月19日 12:38:33 UTC (rev 6681) @@ -95,7 +95,7 @@ rm -rf upload &&\ mkdir upload &&\ cp matplotlib-${MPLVERSION}.tar.gz upload/ &&\ - cp matplotlib-${MPLVERSION}/dist/matplotlib-${MPLVERSION}_r0-py2.5-macosx-10.5-i386.egg upload/matplotlib-${MPLVERSION}-py2.5.egg &&\ + cp matplotlib-${MPLVERSION}/dist/matplotlib-${MPLVERSION}_r0-py2.5-macosx-10.3-fat.egg upload/matplotlib-${MPLVERSION}-py2.5.egg &&\ cp matplotlib-${MPLVERSION}/dist/matplotlib-${MPLVERSION}-py2.5-macosx10.5.zip upload/matplotlib-${MPLVERSION}-py2.5-mpkg.zip&&\ scp upload/* jd...@fr...:uploads/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6680 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6680&view=rev Author: jdh2358 Date: 2008年12月19日 12:30:33 +0000 (2008年12月19日) Log Message: ----------- added macosx.m to manifest; released 98.5.2 tarball Modified Paths: -------------- branches/v0_98_5_maint/CHANGELOG Modified: branches/v0_98_5_maint/CHANGELOG =================================================================== --- branches/v0_98_5_maint/CHANGELOG 2008年12月19日 12:29:49 UTC (rev 6679) +++ branches/v0_98_5_maint/CHANGELOG 2008年12月19日 12:30:33 UTC (rev 6680) @@ -1,6 +1,6 @@ ======================================================================= -Re-Released 0.98.5.2 at r6675 +Re-Released 0.98.5.2 at r6679 Release 0.98.5.2 at r6667 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6679 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6679&view=rev Author: jdh2358 Date: 2008年12月19日 12:29:49 +0000 (2008年12月19日) Log Message: ----------- added macosx.m to manifest Modified Paths: -------------- branches/v0_98_5_maint/MANIFEST.in Modified: branches/v0_98_5_maint/MANIFEST.in =================================================================== --- branches/v0_98_5_maint/MANIFEST.in 2008年12月18日 20:20:18 UTC (rev 6678) +++ branches/v0_98_5_maint/MANIFEST.in 2008年12月19日 12:29:49 UTC (rev 6679) @@ -16,7 +16,7 @@ recursive-include license LICENSE* recursive-include examples * recursive-include doc * -recursive-include src *.cpp *.c *.h +recursive-include src *.cpp *.c *.h *.m recursive-include CXX *.cxx *.hxx *.c *.h recursive-include agg24 * recursive-include lib * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.