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

Commitb676ca1

Browse files
committed
LogitLocator: allows nonsingular works with no plotted values
solves#14743
1 parent3fb246c commitb676ca1

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

‎lib/matplotlib/ticker.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,33 +2792,46 @@ def ideal_ticks(x):
27922792
returnMaxNLocator.tick_values(self,vmin,vmax)
27932793

27942794
defnonsingular(self,vmin,vmax):
2795-
initial_range= (1e-7,1-1e-7)
2796-
ifnotnp.isfinite(vmin)ornotnp.isfinite(vmax):
2797-
returninitial_range# no data plotted yet
2798-
2795+
standard_minpos=1e-7
2796+
initial_range= (standard_minpos,1-standard_minpos)
2797+
swap_vlims=False
27992798
ifvmin>vmax:
2799+
swap_vlims=True
28002800
vmin,vmax=vmax,vmin
2801-
2802-
# what to do if a window beyond ]0, 1[ is chosen
2803-
ifself.axisisnotNone:
2804-
minpos=self.axis.get_minpos()
2805-
ifnotnp.isfinite(minpos):
2806-
returninitial_range# again, no data plotted
2801+
ifnotnp.isfinite(vmin)ornotnp.isfinite(vmax):
2802+
vmin,vmax=initial_range# Initial range, no data plotted yet.
2803+
elifvmax<=0:
2804+
cbook._warn_external(
2805+
"Data has no positive values, and therefore cannot be "
2806+
"logit-scaled."
2807+
)
2808+
vmin,vmax=initial_range
2809+
elifvmin>=1:
2810+
cbook._warn_external(
2811+
"Data has no values smaller than one, and therefore cannot "
2812+
"be logit-scaled."
2813+
)
2814+
vmin,vmax=initial_range
28072815
else:
2808-
minpos=1e-7# should not occur in normal use
2809-
2810-
# NOTE: for vmax, we should query a property similar to get_minpos, but
2811-
# related to the maximal, less-than-one data point. Unfortunately,
2812-
# Bbox._minpos is defined very deep in the BBox and updated with data,
2813-
# so for now we use 1 - minpos as a substitute.
2814-
2815-
ifvmin<=0:
2816-
vmin=minpos
2817-
ifvmax>=1:
2818-
vmax=1-minpos
2819-
ifvmin==vmax:
2820-
return0.1*vmin,1-0.1*vmin
2821-
2816+
minpos= (
2817+
self.axis.get_minpos()
2818+
ifself.axisisnotNone
2819+
elsestandard_minpos
2820+
)
2821+
ifnotnp.isfinite(minpos):
2822+
minpos=standard_minpos# This should never take effect.
2823+
ifvmin<=0:
2824+
vmin=minpos
2825+
# NOTE: for vmax, we should query a property similar to get_minpos,
2826+
# but related to the maximal, less-than-one data point.
2827+
# Unfortunately, Bbox._minpos is defined very deep in the BBox and
2828+
# updated with data, so for now we use 1 - minpos as a substitute.
2829+
ifvmax>=1:
2830+
vmax=1-minpos
2831+
ifvmin==vmax:
2832+
vmin,vmax=0.1*vmin,1-0.1*vmin
2833+
ifswap_vlims:
2834+
vmin,vmax=vmax,vmin
28222835
returnvmin,vmax
28232836

28242837

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp