Skip to content

Commit

Permalink
Log scale bugfix, add section to axis examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Dec 9, 2019
1 parent 13697b0 commit 9b16473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/axis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@
"plot.rc.reset()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## New axis scales"
]
},
{
"cell_type": "raw",
"metadata": {
Expand Down
6 changes: 4 additions & 2 deletions proplot/axistools.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ class AutoFormatter(mticker.ScalarFormatter):
are labelled.
3. Allows user to add arbitrary prefix or suffix to every
tick label string.
"""

def __init__(self, *args,
zerotrim=None, precision=None, tickrange=None,
prefix=None, suffix=None, **kwargs):
Expand Down Expand Up @@ -407,6 +405,8 @@ def __call__(self, x, pos=None):
return '' # avoid some ticks
# Normal formatting
string = super().__call__(x, pos)
if string == '0' and x != 0: # weird LogScale issue
string = ('{:.%df}' % (self._maxprecision or 6)).format(x)
if self._maxprecision is not None and '.' in string:
head, tail = string.split('.')
string = head + '.' + tail[:self._maxprecision]
Expand All @@ -419,6 +419,8 @@ def __call__(self, x, pos=None):
string = string.replace('-', '\N{MINUS SIGN}')
if string and string[0] == '\N{MINUS SIGN}':
sign, string = string[0], string[1:]
# if 0 < x < 1:
# print(x, repr(string))
return sign + self._prefix + string + self._suffix


Expand Down

0 comments on commit 9b16473

Please sign in to comment.