@@ -251,7 +251,7 @@ Plotly.plot = function(gd, data, layout, config) {
251251 subplots = Plots . getSubplotIds ( fullLayout , 'cartesian' ) ,
252252 modules = gd . _modules ;
253253
254- var i , j , cd , trace , uid , subplot , subplotInfo ,
254+ var i , j , trace , subplot , subplotInfo ,
255255 cdSubplot , cdError , cdModule , _module ;
256256
257257 function getCdSubplot ( calcdata , subplot ) {
@@ -293,17 +293,20 @@ Plotly.plot = function(gd, data, layout, config) {
293293 // in case of traces that were heatmaps or contour maps
294294 // previously, remove them and their colorbars explicitly
295295 for ( i = 0 ; i < calcdata . length ; i ++ ) {
296- cd = calcdata [ i ] ;
297- trace = cd [ 0 ] . trace ;
298- if ( trace . visible !== true || ! trace . _module . colorbar ) {
296+ trace = calcdata [ i ] [ 0 ] . trace ;
297+
298+ var isVisible = ( trace . visible === true ) ,
299299 uid = trace . uid ;
300300
301+ if ( ! isVisible || ! Plots . traceIs ( trace , '2dMap' ) ) {
301302 fullLayout . _paper . selectAll (
302303 '.hm' + uid +
303304 ',.contour' + uid +
304305 ',#clip' + uid
305306 ) . remove ( ) ;
307+ }
306308
309+ if ( ! isVisible || ! trace . _module . colorbar ) {
307310 fullLayout . _infolayer . selectAll ( '.cb' + uid ) . remove ( ) ;
308311 }
309312 }
0 commit comments