From: <md...@us...> - 2010-10-19 14:30:32
|
Revision: 8757 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8757&view=rev Author: mdboom Date: 2010-10-19 14:30:24 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Merged revisions 8754-8756 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8754 | jdh2358 | 2010-10-15 09:34:49 -0400 (Fri, 15 Oct 2010) | 1 line added chipy talk video and some notes about transforms ........ r8755 | mdboom | 2010-10-19 08:44:14 -0400 (Tue, 19 Oct 2010) | 2 lines Make is_decade safe for non-finite values. ........ r8756 | mdboom | 2010-10-19 10:16:23 -0400 (Tue, 19 Oct 2010) | 2 lines Fix LogFormatter, as reported by G?\195?\182khan Sever ........ Modified Paths: -------------- trunk/matplotlib/doc/_templates/indexsidebar.html trunk/matplotlib/doc/users/transforms_tutorial.rst trunk/matplotlib/lib/matplotlib/ticker.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8752 /trunk/matplotlib:1-7315 + /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8756 /trunk/matplotlib:1-7315 Modified: trunk/matplotlib/doc/_templates/indexsidebar.html =================================================================== --- trunk/matplotlib/doc/_templates/indexsidebar.html 2010-10-19 14:16:23 UTC (rev 8756) +++ trunk/matplotlib/doc/_templates/indexsidebar.html 2010-10-19 14:30:24 UTC (rev 8757) @@ -27,7 +27,12 @@ <p>Watch the <a href="http://conference.scipy.org/">SciPy</a> 2009 <a href="http://www.archive.org/details/scipy09_introTutorialDay2_1">intro</a> and <a href="http://www.archive.org/details/scipy09_advancedTutorialDay1_3">advanced</a> matplotlib tutorials </p> -<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">talk</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>MLOSS</i></a>. +<p>Watch +a <a href="http://videolectures.net/mloss08_hunter_mat">talk</a> about +matplotlib presented +at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 +Workshop</a> <i>MLOSS</i></a> and one <a href="http://carlfk.blip.tv/file/2557425">presented</a> +at <a href="http://chipy.org">ChiPy</a>. </p> Modified: trunk/matplotlib/doc/users/transforms_tutorial.rst =================================================================== --- trunk/matplotlib/doc/users/transforms_tutorial.rst 2010-10-19 14:16:23 UTC (rev 8756) +++ trunk/matplotlib/doc/users/transforms_tutorial.rst 2010-10-19 14:30:24 UTC (rev 8757) @@ -261,15 +261,27 @@ plt.show() +.. note:: + The blended transformations where x is in data coords and y in axes + coordinates is so useful that we have helper methods to return the + versions mpl uses internally for drawing ticks, ticklabels, etc. + The methods are :meth:`matplotlib.axes.Axes.get_xaxis_transform` and + :meth:`matplotlib.axes.Axes.get_yaxis_transform`. So in the example + above, the call to + :meth:`~matplotlib.transforms.blended_transform_factory` can be + replaced by ``get_xaxis_transform``:: + + trans = ax.get_xaxis_transform() + .. offset-transforms-shadow: Using offset transforms to create a shadow effect ================================================= One use of transformations is to create a new transformation that is -offset from another annotation, eg to place one object shifted a bit -relative to another object. Typically you want the shift to be in +offset from another transformation, eg to place one object shifted a +bit relative to another object. Typically you want the shift to be in some physical dimension, like points or inches rather than in data coordinates, so that the shift effect is constant at different zoom levels and dpi settings. @@ -301,8 +313,11 @@ shadow_transform = ax.transData + offset showing that can chain transformations using the addition operator. -This code says: first apply the data transformation ``ax.transData`` and -then translate the data by `dx` and `dy` points. +This code says: first apply the data transformation ``ax.transData`` +and then translate the data by `dx` and `dy` points. In typography, +a`point <http://en.wikipedia.org/wiki/Point_%28typography%29>`_ is +1/72 inches, and by specifying your offsets in points, your figure +will look the same regardless of the dpi resolution it is saved in. .. plot:: :include-source: Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-19 14:16:23 UTC (rev 8756) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-19 14:30:24 UTC (rev 8757) @@ -607,7 +607,7 @@ sign = np.sign(x) # only label the decades fx = math.log(abs(x))/math.log(b) - isDecade = is_decade(fx) + isDecade = is_close_to_int(fx) if not isDecade and self.labelOnlyBase: s = '' #if 0: pass elif fx>10000: s= '%1.0e'%fx @@ -629,15 +629,18 @@ def __call__(self, x, pos=None): 'Return the format for tick val *x* at position *pos*' b = self._base + usetex = rcParams['text.usetex'] + # only label the decades if x == 0: - return '$0$' + if usetex: + return '$0$' + else: + return '$\mathdefault{0}$' sign = np.sign(x) fx = math.log(abs(x))/math.log(b) - isDecade = is_decade(fx) + isDecade = is_close_to_int(fx) - usetex = rcParams['text.usetex'] - if sign == -1: sign_string = '-' else: @@ -1186,11 +1189,18 @@ else: return long(x-0.5) def is_decade(x, base=10): + if not np.isfinite(x): + return False if x == 0.0: return True lx = np.log(x)/np.log(base) - return abs(lx - nearest_long(lx)) < 1e-10 + return is_close_to_int(lx) +def is_close_to_int(x): + if not np.isfinite(x): + return False + return abs(x - nearest_long(x)) < 1e-10 + class LogLocator(Locator): """ Determine the tick locations for log axes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |