@@ -451,6 +451,7 @@ def __init__(self, ax, cmap=None,
451
451
self .locator = None
452
452
self .formatter = None
453
453
self ._manual_tick_data_values = None
454
+ self .__scale = None # linear, log10 for now. Hopefully more?
454
455
455
456
if ticklocation == 'auto' :
456
457
ticklocation = 'bottom' if orientation == 'horizontal' else 'right'
@@ -584,8 +585,8 @@ def _use_auto_colorbar_locator(self):
584
585
one. (check is used twice so factored out here...)
585
586
"""
586
587
contouring = self .boundaries is not None and self .spacing == 'uniform'
587
- return (type (self .norm ) in [colors .Normalize , colors .LogNorm ]
588
- and not contouring )
588
+ return (type (self .norm ) in [colors .Normalize , colors .LogNorm ] and
589
+ not contouring )
589
590
590
591
def _reset_locator_formatter_scale (self ):
591
592
"""
@@ -601,9 +602,14 @@ def _reset_locator_formatter_scale(self):
601
602
self .ax .set_xscale ('log' )
602
603
self .ax .set_yscale ('log' )
603
604
self .minorticks_on ()
605
+ self .__scale = 'log'
604
606
else :
605
607
self .ax .set_xscale ('linear' )
606
608
self .ax .set_yscale ('linear' )
609
+ if type (self .norm ) is colors .Normalize :
610
+ self .__scale = 'linear'
611
+ else :
612
+ self .__scale = 'manual'
607
613
608
614
def update_ticks (self ):
609
615
"""
@@ -1118,13 +1124,13 @@ def _mesh(self):
1118
1124
else :
1119
1125
y = self ._proportional_y ()
1120
1126
xmid = np .array ([0.5 ])
1121
- try :
1127
+ if self . __scale != 'manual' :
1122
1128
y = norm .inverse (y )
1123
1129
x = norm .inverse (x )
1124
1130
xmid = norm .inverse (xmid )
1125
- except ValueError :
1126
- # occurs for norms that don 't have an inverse, in
1127
- # which case manually scale:
1131
+ else :
1132
+ # if a norm doesn 't have a named scale, or
1133
+ # we are not using a norm
1128
1134
dv = self .vmax - self .vmin
1129
1135
x = x * dv + self .vmin
1130
1136
y = y * dv + self .vmin
0 commit comments