| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The scale passed to the `pprint_val` method needs to also be scaled by the log so that the range used to format the tick labels matches the actual range of the tick labels (not the underlying values). reported via http://stackoverflow.com/questions/33975758/matplotlib-logformatterexponent-e-in-the-exponent-labels-of-cbar
|
Sigh, meant to target this against v2.0.x, oh well. |
Sorry, something went wrong.
Makes sure that there are never trailing 'e' with no exponent.
Code used to generate the test data to establish bench mark.
First print out is human-readable, second is for testing
import itertools
import matplotlib.ticker as mticker
import numpy as np
domains = sorted([1e-3, 1.5e-2, 1e6, 100, 5, .5])
float_values = sorted([np.pi * (10**i) for i in range(-5, 6)])
int_values = sorted([1 * (10 ** i) for i in range(-5, 6)])
fmt = mticker.LogFormatter()
print()
for d in domains:
print('Domain ', d)
for f in float_values:
print(' {: >10.7f}: {: <10}'.format(f, fmt.pprint_val(f, d)))
for f in int_values:
print(' {: >10g}: {: <10}'.format(f, fmt.pprint_val(f, d)))
print()
print()
print(',\n'.join([' ({v:.10g}, {d!r}, {res!r})'.format(
v=f, d=d, res=fmt.pprint_val(f, d))
for d, f in itertools.product(
domains, float_values + int_values)]))
Domain 0.001
0.0000314: 3.142e-5
0.0003142: 3.142e-4
0.0031416: 3.142e-3
0.0314159: 3.142e-2
0.3141593: 3.142e-1
3.1415927: 3.142
31.4159265: 3.142e1
314.1592654: 3.142e2
3141.5926536: 3.142e3
31415.9265359: 3.142e4
314159.2653590: 3.142e5
1e-05: 1e-5
0.0001: 1e-4
0.001: 1e-3
0.01: 1e-2
0.1: 1e-1
1: 1
10: 10
100: 100
1000: 1000
10000: 1e4
100000: 1e5
Domain 0.015
0.0000314: 0
0.0003142: 0
0.0031416: 0.003
0.0314159: 0.031
0.3141593: 0.314
3.1415927: 3.142
31.4159265: 31.416
314.1592654: 314.159
3141.5926536: 3141.593
31415.9265359: 31415.927
314159.2653590: 314159.265
1e-05: 0
0.0001: 0
0.001: 0.001
0.01: 0.01
0.1: 0.1
1: 1
10: 10
100: 100
1000: 1000
10000: 10000
100000: 100000
Domain 0.5
0.0000314: 0
0.0003142: 0
0.0031416: 0.003
0.0314159: 0.031
0.3141593: 0.314
3.1415927: 3.142
31.4159265: 31.416
314.1592654: 314.159
3141.5926536: 3141.593
31415.9265359: 31415.927
314159.2653590: 314159.265
1e-05: 0
0.0001: 0
0.001: 0.001
0.01: 0.01
0.1: 0.1
1: 1
10: 10
100: 100
1000: 1000
10000: 10000
100000: 100000
Domain 5
0.0000314: 0
0.0003142: 0
0.0031416: 0
0.0314159: 0.03
0.3141593: 0.31
3.1415927: 3.14
31.4159265: 31.42
314.1592654: 314.16
3141.5926536: 3141.59
31415.9265359: 31415.93
314159.2653590: 314159.27
1e-05: 0
0.0001: 0
0.001: 0
0.01: 0.01
0.1: 0.1
1: 1
10: 10
100: 100
1000: 1000
10000: 10000
100000: 100000
Domain 100
0.0000314: 0
0.0003142: 0
0.0031416: 0
0.0314159: 0
0.3141593: 0.3
3.1415927: 3.1
31.4159265: 31.4
314.1592654: 314.2
3141.5926536: 3141.6
31415.9265359: 31415.9
314159.2653590: 314159.3
1e-05: 0
0.0001: 0
0.001: 0
0.01: 0
0.1: 0.1
1: 1
10: 10
100: 100
1000: 1000
10000: 10000
100000: 100000
Domain 1000000.0
0.0000314: 3.1e-5
0.0003142: 3.1e-4
0.0031416: 3.1e-3
0.0314159: 3.1e-2
0.3141593: 3.1e-1
3.1415927: 3.1
31.4159265: 3.1e1
314.1592654: 3.1e2
3141.5926536: 3.1e3
31415.9265359: 3.1e4
314159.2653590: 3.1e5
1e-05: 1e-5
0.0001: 1e-4
0.001: 1e-3
0.01: 1e-2
0.1: 1e-1
1: 1
10: 10
100: 100
1000: 1000
10000: 1e4
100000: 1e5
These are now the results of pprint_val for all of the domains in a human-readable form. |
Sorry, something went wrong.
|
👍 |
Sorry, something went wrong.
FIX: formatting in LogFormatterExponent
FIX: formatting in LogFormatterExponent
…onent FIX: formatting in LogFormatterExponent
|
Backport to v2.x is actually via 5ff7e37. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The scale passed to the pprint_val method needs to also be
scaled by the log so that the range used to format the tick labels
matches the actual range of the tick labels (not the underlying values).
reported via http://stackoverflow.com/questions/33975758/matplotlib-logformatterexponent-e-in-the-exponent-labels-of-cbar
More coming on pprint_val