18
18
is a thin wrapper over :meth:`~matplotlib.figure.Figure.colorbar`.
19
19
20
20
'''
21
-
21
+ import copy
22
22
import logging
23
23
24
24
import numpy as np
@@ -484,6 +484,7 @@ def draw_all(self):
484
484
# units:
485
485
X , Y = self ._mesh ()
486
486
C = self ._values [:, np .newaxis ]
487
+ # decide minor/major axis
487
488
self .config_axis ()
488
489
self ._config_axes (X , Y )
489
490
if self .filled :
@@ -560,10 +561,8 @@ def _use_auto_colorbar_locator(self):
560
561
Return if we should use an adjustable tick locator or a fixed
561
562
one. (check is used twice so factored out here...)
562
563
"""
563
- return (self .boundaries is None
564
- and self .values is None
565
- and ((type (self .norm ) == colors .Normalize )
566
- or (type (self .norm ) == colors .LogNorm )))
564
+ return ((type (self .norm ) == colors .Normalize )
565
+ or (type (self .norm ) == colors .LogNorm ))
567
566
568
567
def _reset_locator_formatter_scale (self ):
569
568
"""
@@ -573,13 +572,11 @@ def _reset_locator_formatter_scale(self):
573
572
"""
574
573
self .locator = None
575
574
self .formatter = None
576
- if (isinstance (self .norm , colors .LogNorm )
577
- and self ._use_auto_colorbar_locator ()):
575
+ if (isinstance (self .norm , colors .LogNorm )):
578
576
# *both* axes are made log so that determining the
579
577
# mid point is easier.
580
578
self .ax .set_xscale ('log' )
581
579
self .ax .set_yscale ('log' )
582
-
583
580
self .minorticks_on ()
584
581
else :
585
582
self .ax .set_xscale ('linear' )
@@ -1068,26 +1065,29 @@ def _mesh(self):
1068
1065
These are suitable for a vertical colorbar; swapping and
1069
1066
transposition for a horizontal colorbar are done outside
1070
1067
this function.
1071
- '''
1072
- # if boundaries and values are None, then we can go ahead and
1073
- # scale this up for Auto tick location. Otherwise we
1074
- # want to keep normalized between 0 and 1 and use manual tick
1075
- # locations.
1076
1068
1069
+ These are scaled between vmin and vmax
1070
+ '''
1071
+ norm = copy .copy (self .norm )
1072
+ norm .vmin = self .vmin
1073
+ norm .vmax = self .vmax
1077
1074
x = np .array ([0.0 , 1.0 ])
1078
1075
if self .spacing == 'uniform' :
1079
1076
y = self ._uniform_y (self ._central_N ())
1080
1077
else :
1081
1078
y = self ._proportional_y ()
1082
- if self ._use_auto_colorbar_locator ():
1083
- y = self .norm .inverse (y )
1084
- x = self .norm .inverse (x )
1079
+ xmid = np .array ([0.5 ])
1080
+ try :
1081
+ y = norm .inverse (y )
1082
+ x = norm .inverse (x )
1083
+ xmid = norm .inverse (xmid )
1084
+ except ValueError :
1085
+ dv = self .vmax - self .vmin
1086
+ x = x * dv + self .vmin
1087
+ y = y * dv + self .vmin
1088
+ xmid = xmid * dv + self .vmin
1085
1089
self ._y = y
1086
1090
X , Y = np .meshgrid (x , y )
1087
- if self ._use_auto_colorbar_locator ():
1088
- xmid = self .norm .inverse (0.5 )
1089
- else :
1090
- xmid = 0.5
1091
1091
if self ._extend_lower () and not self .extendrect :
1092
1092
X [0 , :] = xmid
1093
1093
if self ._extend_upper () and not self .extendrect :
0 commit comments