@@ -485,6 +485,7 @@ def __init__(self, ax, cmap=None,
485
485
self .locator = None
486
486
self .formatter = None
487
487
self ._manual_tick_data_values = None
488
+ self .__scale = None # linear, log10 for now. Hopefully more?
488
489
489
490
if ticklocation == 'auto' :
490
491
ticklocation = 'bottom' if orientation == 'horizontal' else 'right'
@@ -611,11 +612,9 @@ def _use_auto_colorbar_locator(self):
611
612
Return if we should use an adjustable tick locator or a fixed
612
613
one. (check is used twice so factored out here...)
613
614
"""
614
- contouring = ((self .boundaries is not None ) and
615
- (self .spacing == 'uniform' ))
616
- return (((type (self .norm ) == colors .Normalize )
617
- or (type (self .norm ) == colors .LogNorm ))
618
- and not contouring )
615
+ contouring = self .boundaries is not None and self .spacing == 'uniform'
616
+ return (type (self .norm ) in [colors .Normalize , colors .LogNorm ] and
617
+ not contouring )
619
618
620
619
def _reset_locator_formatter_scale (self ):
621
620
"""
@@ -631,9 +630,14 @@ def _reset_locator_formatter_scale(self):
631
630
self .ax .set_xscale ('log' )
632
631
self .ax .set_yscale ('log' )
633
632
self .minorticks_on ()
633
+ self .__scale = 'log'
634
634
else :
635
635
self .ax .set_xscale ('linear' )
636
636
self .ax .set_yscale ('linear' )
637
+ if type (self .norm ) is colors .Normalize :
638
+ self .__scale = 'linear'
639
+ else :
640
+ self .__scale = 'manual'
637
641
638
642
def update_ticks (self ):
639
643
"""
@@ -1123,13 +1127,13 @@ def _mesh(self):
1123
1127
else :
1124
1128
y = self ._proportional_y ()
1125
1129
xmid = np .array ([0.5 ])
1126
- try :
1130
+ if self . __scale != 'manual' :
1127
1131
y = norm .inverse (y )
1128
1132
x = norm .inverse (x )
1129
1133
xmid = norm .inverse (xmid )
1130
- except ValueError :
1131
- # occurs for norms that don 't have an inverse, in
1132
- # which case manually scale:
1134
+ else :
1135
+ # if a norm doesn 't have a named scale, or
1136
+ # we are not using a norm
1133
1137
dv = self .vmax - self .vmin
1134
1138
x = x * dv + self .vmin
1135
1139
y = y * dv + self .vmin
0 commit comments