Revision: 8756 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8756&view=rev Author: mdboom Date: 2010-10-19 14:16:23 +0000 (Tue, 19 Oct 2010)
Log Message: ----------- Fix LogFormatter, as reported by G?\195?\182khan Sever Modified Paths: -------------- branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.png branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.svg branches/v1_0_maint/lib/matplotlib/ticker.py Modified: branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf =================================================================== (Binary files differ) Modified: branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.png =================================================================== (Binary files differ) Modified: branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.svg =================================================================== --- branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.svg 2010-10-19 12:44:14 UTC (rev 8755) +++ branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_axes/symlog.svg 2010-10-19 14:16:23 UTC (rev 8756) @@ -11,12 +11,12 @@ <g id="figure1"> <g id="patch1"> <path style="fill: #ffffff; stroke: #ffffff; stroke-width: 1.000000; stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000" d="M0.000000 432.000000L576.000000 432.000000L576.000000 0.000000 -L0.000000 0.000000L0.000000 432.000000"/> +L0.000000 0.000000z"/> </g> <g id="axes1"> <g id="patch2"> <path style="fill: #ffffff; opacity: 1.000000" d="M72.000000 388.800000L518.400000 388.800000L518.400000 43.200000 -L72.000000 43.200000L72.000000 388.800000"/> +L72.000000 43.200000z"/> </g> <g id="line2d1"> <defs> @@ -136,12 +136,9 @@ <g ><use style="fill: none; stroke: #000000; stroke-width: 0.500000; stroke-linejoin: round; stroke-linecap: butt; opacity: 1.000000" xlink:href="#m20b58b2501143cb5e0a5e8f1ef6f1643" x="518.400000" y="381.525282"/> </g></g> <g id="text7"> -<defs> -<path id="c_f47f2818876b2f1a61c47f270461e46e" d="M25.000000 2.203125q-12.250000 0.000000 -16.671875 -10.078125q-4.421875 -10.093750 -4.421875 -24.015625q0.000000 -8.687500 1.578125 -16.343750q1.593750 -7.671875 6.296875 -13.015625q4.718750 -5.359375 13.218750 -5.359375q6.593750 0.000000 10.781250 3.234375q4.203125 3.218750 6.406250 8.328125q2.203125 5.093750 3.000000 10.937500q0.812500 5.828125 0.812500 12.218750q0.000000 8.593750 -1.593750 16.093750q-1.578125 7.500000 -6.218750 12.750000q-4.640625 5.250000 -13.187500 5.250000M25.000000 -0.390625q5.562500 0.000000 8.296875 -5.703125q2.734375 -5.718750 3.375000 -12.656250q0.640625 -6.937500 0.640625 -14.750000q0.000000 -7.515625 -0.640625 -13.859375q-0.640625 -6.359375 -3.359375 -11.500000q-2.703125 -5.156250 -8.312500 -5.156250q-5.656250 0.000000 -8.390625 5.187500q-2.734375 5.171875 -3.375000 11.500000q-0.640625 6.312500 -0.640625 13.828125q0.000000 5.562500 0.265625 10.500000q0.281250 4.937500 1.453125 10.187500q1.171875 5.250000 3.781250 8.843750q2.609375 3.578125 6.906250 3.578125"/> -</defs> <g id="mathtext1"> -<g style="fill: #000000" transform="translate(62.000000,386.025282)"> -<use xlink:href="#c_f47f2818876b2f1a61c47f270461e46e" transform="translate(0.000000,-1.000000)scale(0.120000)"/> +<g style="fill: #000000" transform="translate(60.000000,386.525282)"> +<use xlink:href="#c_7a2040fe3b94fcd41d0a72c84e93b115" transform="translate(0.000000,-1.093750)scale(0.120000)"/> </g> </g> </g> Modified: branches/v1_0_maint/lib/matplotlib/ticker.py =================================================================== --- branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-19 12:44:14 UTC (rev 8755) +++ branches/v1_0_maint/lib/matplotlib/ticker.py 2010-10-19 14:16:23 UTC (rev 8756) @@ -608,7 +608,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 @@ -630,15 +630,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: @@ -1187,13 +1190,18 @@ else: return long(x-0.5) def is_decade(x, base=10): -y if not np.isfinite(x): + if not np.isfinite(x): return False if x == 0.0: return True lx = math.log(x)/math.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. ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins