@@ -2577,69 +2577,50 @@ def tick_values(self, vmin, vmax):
25772577 #
25782578 # "simple" mode is when the range falls entirely within (-t,
25792579 # t) -- it should just display (vmin, 0, vmax)
2580+ if - linthresh < vmin < vmax < linthresh :
2581+ # only the linear range is present
2582+ return [vmin , vmax ]
25802583
2581- # Determine which of the three ranges we have
2582- has_a = has_b = has_c = False
2583- if vmin < - linthresh :
2584- has_a = True
2585- if vmax > - linthresh :
2586- has_b = True
2587- if vmax > linthresh :
2588- has_c = True
2589- elif vmin < 0 :
2590- if vmax > 0 :
2591- has_b = True
2592- if vmax > linthresh :
2593- has_c = True
2594- else :
2595- return [vmin , vmax ]
2596- elif vmin < linthresh :
2597- if vmax > linthresh :
2598- has_b = True
2599- has_c = True
2600- else :
2601- return [vmin , vmax ]
2602- else :
2603- has_c = True
2584+ # Lower log range is present
2585+ has_a = (vmin < - linthresh )
2586+ # Upper log range is present
2587+ has_c = (vmax > linthresh )
2588+
2589+ # Check if linear range is present
2590+ has_b = (has_a and vmax > - linthresh ) or (has_c and vmin < linthresh )
26042591
26052592 def get_log_range (lo , hi ):
26062593 lo = np .floor (np .log (lo ) / np .log (base ))
26072594 hi = np .ceil (np .log (hi ) / np .log (base ))
26082595 return lo , hi
26092596
26102597 # Calculate all the ranges, so we can determine striding
2598+ a_lo , a_hi = (0 , 0 )
26112599 if has_a :
2612- if has_b :
2613- a_range = get_log_range (linthresh , np .abs (vmin ) + 1 )
2614- else :
2615- a_range = get_log_range (np .abs (vmax ), np .abs (vmin ) + 1 )
2616- else :
2617- a_range = (0 , 0 )
2600+ a_upper_lim = min (- linthresh , vmax )
2601+ a_lo , a_hi = get_log_range (np .abs (a_upper_lim ), np .abs (vmin ) + 1 )
26182602
2603+ c_lo , c_hi = (0 , 0 )
26192604 if has_c :
2620- if has_b :
2621- c_range = get_log_range (linthresh , vmax + 1 )
2622- else :
2623- c_range = get_log_range (vmin , vmax + 1 )
2624- else :
2625- c_range = (0 , 0 )
2605+ c_lower_lim = max (linthresh , vmin )
2606+ c_lo , c_hi = get_log_range (c_lower_lim , vmax + 1 )
26262607
26272608 # Calculate the total number of integer exponents in a and c ranges
2628- total_ticks = (a_range [ 1 ] - a_range [ 0 ] ) + (c_range [ 1 ] - c_range [ 0 ] )
2609+ total_ticks = (a_hi - a_lo ) + (c_hi - c_lo )
26292610 if has_b :
26302611 total_ticks += 1
26312612 stride = max (total_ticks // (self .numticks - 1 ), 1 )
26322613
26332614 decades = []
26342615 if has_a :
2635- decades .extend (- 1 * (base ** (np .arange (a_range [ 0 ], a_range [ 1 ] ,
2616+ decades .extend (- 1 * (base ** (np .arange (a_lo , a_hi ,
26362617 stride )[::- 1 ])))
26372618
26382619 if has_b :
26392620 decades .append (0.0 )
26402621
26412622 if has_c :
2642- decades .extend (base ** (np .arange (c_range [ 0 ], c_range [ 1 ] , stride )))
2623+ decades .extend (base ** (np .arange (c_lo , c_hi , stride )))
26432624
26442625 # Add the subticks if requested
26452626 if self ._subs is None :
0 commit comments