@@ -60,26 +60,28 @@ module.exports = function makeColorMap(trace) {
60
60
range . push ( range [ range . length - 1 ] ) ;
61
61
}
62
62
} else {
63
+ var zRangeInput = trace . _input && (
64
+ typeof trace . _input . zmin === 'number' && typeof trace . _input . zmax === 'number'
65
+ ) ;
66
+
67
+ // If zmin/zmax are explicitly set, consider case where user specifies a
68
+ // narrower z range than that of the contours start/end.
69
+ if ( zRangeInput && ( start <= zmin0 || end >= zmax0 ) ) {
70
+ if ( start <= zmin0 ) start = zmin0 ;
71
+ if ( end >= zmax0 ) end = zmax0 ;
72
+ nc = Math . floor ( ( end - start ) / cs ) + 1 ;
73
+ extra = 0 ;
74
+ }
75
+
63
76
for ( i = 0 ; i < len ; i ++ ) {
64
77
si = scl [ i ] ;
65
78
domain [ i ] = ( si [ 0 ] * ( nc + extra - 1 ) - ( extra / 2 ) ) * cs + start ;
66
79
range [ i ] = si [ 1 ] ;
67
80
}
68
81
69
- // If zmin/zmax are explicitly set
70
- if ( typeof trace . _input . zmin === 'number' && typeof trace . _input . zmax === 'number' ) {
71
- // Consider case where user specifies a narrower z range than that
72
- // of the contours start/end.
73
- if ( start <= zmin0 ) {
74
- domain = domain . filter ( function ( z ) { return z >= zmin0 ; } ) ;
75
- range . splice ( 0 , range . length - domain . length ) ;
76
- }
77
- if ( end >= zmax0 ) {
78
- domain = domain . filter ( function ( z ) { return z <= zmax0 ; } ) ;
79
- range . splice ( domain . length , range . length - domain . length ) ;
80
- }
81
-
82
- // Make the colorscale fit the z range
82
+ // Make the colorscale fit the z range except if contours are explicitly
83
+ // set BUT NOT zmin/zmax.
84
+ if ( zRangeInput || trace . autocontour ) {
83
85
if ( domain [ 0 ] > zmin0 ) {
84
86
domain . unshift ( zmin0 ) ;
85
87
range . unshift ( range [ 0 ] ) ;
0 commit comments