@@ -60,26 +60,28 @@ module.exports = function makeColorMap(trace) {
6060 range . push ( range [ range . length - 1 ] ) ;
6161 }
6262 } 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+
6376 for ( i = 0 ; i < len ; i ++ ) {
6477 si = scl [ i ] ;
6578 domain [ i ] = ( si [ 0 ] * ( nc + extra - 1 ) - ( extra / 2 ) ) * cs + start ;
6679 range [ i ] = si [ 1 ] ;
6780 }
6881
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 ) {
8385 if ( domain [ 0 ] > zmin0 ) {
8486 domain . unshift ( zmin0 ) ;
8587 range . unshift ( range [ 0 ] ) ;
0 commit comments