Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposed change to default log scale tick formatting#5161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 9 commits intomatplotlib:masterfromzblz:log-ticks
Aug 22, 2016
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
generalize label location for all bases
fix pep8fix close to decade coefficients
  • Loading branch information
@zblz
zblz committedAug 2, 2016
commita6e954d87acd83b6f96cd166b25b8cfb4f487cdc
25 changes: 13 additions & 12 deletionslib/matplotlib/ticker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -910,6 +910,7 @@ def pprint_val(self, x, d):
s = s.rstrip('0').rstrip('.')
return s


class LogFormatterExponent(LogFormatter):
"""
Format values for log axis using ``exponent = log_base(value)``.
Expand DownExpand Up@@ -999,6 +1000,7 @@ def __call__(self, x, pos=None):
'%s%s^{%d}' %
(sign_string, base, nearest_long(fx))))


class LogFormatterSciNotation(LogFormatterMathtext):
"""
Format values following scientific notation in a logarithmic axis
Expand All@@ -1022,6 +1024,7 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
return (r'$\mathdefault{%g\times%s^{%d}}$') % \
(coeff, base, exponent)


class LogitFormatter(Formatter):
"""
Probability formatter (using Math text).
Expand DownExpand Up@@ -1932,22 +1935,20 @@ def show_tick_label(self, ticklocs):
numdec = abs(vmax - vmin)

if numdec > 3:
# Label only bases
sublabel = set((1,))
elif numdec > 2:
sublabel = set((1, 3))
elif numdec > 1:
sublabel = set((1, 2, 5))
else:
sublabel = set((1, 2, 4, 7))
# Add labels between bases at log-spaced coefficients
c = np.logspace(0, 1, (4 - int(numdec)) + 1, base=b)
sublabel = set(np.round(c))

label = np.ones(ticklocs.size, dtype=np.bool)
for i, loc in enumerate(ticklocs):
exponent = math.floor(math.log(abs(loc)) / math.log(b))
coeff = loc / b ** nearest_long(exponent)
if nearest_long(coeff) not in sublabel:
label[i] = False
fx = np.log(abs(ticklocs)) / np.log(b)
exponents = np.array([np.round(x) if is_close_to_int(x)
else np.floor(x)
for x in fx])
coeffs = np.round(ticklocs / b ** exponents)

returnlabel
return[c in sublabel for c in coeffs]

def view_limits(self, vmin, vmax):
'Try to choose the view limits intelligently'
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp