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