diff --git a/src/components/colorbar/draw.js b/src/components/colorbar/draw.js
index b01ff451a37..26e21280802 100644
--- a/src/components/colorbar/draw.js
+++ b/src/components/colorbar/draw.js
@@ -228,7 +228,8 @@ function drawColorBar(g, opts, gd) {
     opts._xLeftFrac = xLeftFrac;
     opts._yBottomFrac = yBottomFrac;
 
-    var ax = mockColorBarAxis(gd, opts, zrange);
+    // stash mocked axis for contour label formatting
+    var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
 
     // position can't go in through supplyDefaults
     // because that restricts it to [0,1]
diff --git a/src/traces/contour/plot.js b/src/traces/contour/plot.js
index 1db57c67c0d..f6ce6dd3df5 100644
--- a/src/traces/contour/plot.js
+++ b/src/traces/contour/plot.js
@@ -13,6 +13,7 @@ var d3 = require('d3');
 
 var Lib = require('../../lib');
 var Drawing = require('../../components/drawing');
+var Colorscale = require('../../components/colorscale');
 var svgTextUtils = require('../../lib/svg_text_utils');
 var Axes = require('../../plots/cartesian/axes');
 var setConvert = require('../../plots/cartesian/set_convert');
@@ -236,7 +237,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours) {
         // invalidate the getTextLocation cache in case paths changed
         Lib.clearLocationCache();
 
-        var contourFormat = exports.labelFormatter(contours, cd0.t.cb, gd._fullLayout);
+        var contourFormat = exports.labelFormatter(gd, cd0);
 
         var dummyText = Drawing.tester.append('text')
             .attr('data-notex', 1)
@@ -388,13 +389,18 @@ exports.createLineClip = function(lineContainer, clipLinesForLabels, gd, uid) {
     return lineClip;
 };
 
-exports.labelFormatter = function(contours, colorbar, fullLayout) {
+exports.labelFormatter = function(gd, cd0) {
+    var fullLayout = gd._fullLayout;
+    var trace = cd0.trace;
+    var contours = trace.contours;
+
     if(contours.labelformat) {
         return fullLayout._d3locale.numberFormat(contours.labelformat);
     } else {
         var formatAxis;
-        if(colorbar) {
-            formatAxis = colorbar.axis;
+        var cOpts = Colorscale.extractOpts(trace);
+        if(cOpts && cOpts.colorbar && cOpts.colorbar._axis) {
+            formatAxis = cOpts.colorbar._axis;
         } else {
             formatAxis = {
                 type: 'linear',
diff --git a/src/traces/contourcarpet/plot.js b/src/traces/contourcarpet/plot.js
index 72b93ead062..59d65d605b6 100644
--- a/src/traces/contourcarpet/plot.js
+++ b/src/traces/contourcarpet/plot.js
@@ -182,7 +182,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, plotinfo, ca
         // invalidate the getTextLocation cache in case paths changed
         Lib.clearLocationCache();
 
-        var contourFormat = contourPlot.labelFormatter(contours, cd0.t.cb, gd._fullLayout);
+        var contourFormat = contourPlot.labelFormatter(gd, cd0);
 
         var dummyText = Drawing.tester.append('text')
             .attr('data-notex', 1)
diff --git a/test/image/baselines/contour_label-formatting-via-colorbar.png b/test/image/baselines/contour_label-formatting-via-colorbar.png
new file mode 100644
index 00000000000..5b3ca64cc98
Binary files /dev/null and b/test/image/baselines/contour_label-formatting-via-colorbar.png differ
diff --git a/test/image/mocks/contour_label-formatting-via-colorbar.json b/test/image/mocks/contour_label-formatting-via-colorbar.json
new file mode 100644
index 00000000000..07db07770c2
--- /dev/null
+++ b/test/image/mocks/contour_label-formatting-via-colorbar.json
@@ -0,0 +1,119 @@
+{
+  "data": [
+    {
+      "name": "contour / non-shared",
+      "type": "contour",
+      "z": [
+        [ 10, 10.625, 12.5, 15.625, 20 ],
+        [ 5.625, 6.25, 8.125, 11.25, 15.625 ],
+        [ 2.5, 3.125, 5, 8.125, 12.5 ],
+        [ 0.625, 1.25, 3.125, 6.25, 10.625 ],
+        [ 0, 0.625, 2.5, 5.625, 10 ]
+      ],
+      "contours": { "showlabels": true },
+      "colorbar": {
+        "tickvals": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
+        "ticktext": [ 1, 22, 34, 5, 6, 77, 88, 99, 10101 ],
+        "len": 0.65,
+        "x": -0.05,
+        "xanchor": "right",
+        "y": 1.1,
+        "yanchor": "top"
+      }
+    },
+    {
+      "name": "contour / shared",
+      "type": "contour",
+      "z": [
+        [ 10, 10.625, 12.5, 15.625, 20 ],
+        [ 5.625, 6.25, 8.125, 11.25, 15.625 ],
+        [ 2.5, 3.125, 5, 8.125, 12.5 ],
+        [ 0.625, 1.25, 3.125, 6.25, 10.625 ],
+        [ 0, 0.625, 2.5, 5.625, 10 ]
+      ],
+      "contours": { "showlabels": true },
+      "coloraxis": "coloraxis",
+      "xaxis": "x2",
+      "yaxis": "y2"
+    },
+    {
+      "type": "carpet",
+      "a": [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ],
+      "b": [ 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82 ],
+      "y": [ 4, 4.2, 4.4, 4.6, 4.8, 5, 5.1, 5.3, 5.5, 5.7, 5.9, 6.1, 6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4, 8.8, 9, 9.2, 9.4, 9.6, 9.8 ],
+      "xaxis": "x3",
+      "yaxis": "y3",
+      "carpet": "c1"
+    },
+    {
+      "name": "contourcarpet / non-shared",
+      "type": "contourcarpet",
+      "a": [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ],
+      "b": [ 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82 ],
+      "z": [ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.12, 0.22, 0.32, 0.42, 0.52, 0.62, 0.14, 0.24, 0.34, 0.44, 0.54, 0.64, 0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.18, 0.28, 0.38, 0.48, 0.58, 0.68 ],
+      "contours": { "showlabels": true },
+      "colorbar": {
+        "tickvals": [ 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 ],
+        "ticktext": [ 1, 22, 34, 5, 6, 77, 88, 99, 10101 ],
+        "len": 0.5,
+        "x": -0.094,
+        "xanchor": "right",
+        "y": -0.05,
+        "yanchor": "bottom"
+      },
+      "xaxis": "x3",
+      "yaxis": "y3",
+      "carpet": "c1"
+    },
+    {
+      "type": "carpet",
+      "a": [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ],
+      "b": [ 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82 ],
+      "y": [ 4, 4.2, 4.4, 4.6, 4.8, 5, 5.1, 5.3, 5.5, 5.7, 5.9, 6.1, 6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4, 8.8, 9, 9.2, 9.4, 9.6, 9.8 ],
+      "xaxis": "x4",
+      "yaxis": "y4",
+      "carpet": "c2"
+    },
+    {
+      "name": "contourcarpet / shared",
+      "type": "contourcarpet",
+      "a": [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ],
+      "b": [ 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82, 1.01, 1.12, 1.24, 1.38, 1.56, 1.82 ],
+      "z": [ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.12, 0.22, 0.32, 0.42, 0.52, 0.62, 0.14, 0.24, 0.34, 0.44, 0.54, 0.64, 0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.18, 0.28, 0.38, 0.48, 0.58, 0.68 ],
+      "contours": { "showlabels": true },
+      "coloraxis": "coloraxis2",
+      "xaxis": "x4",
+      "yaxis": "y4",
+      "carpet": "c2"
+    }
+  ],
+  "layout": {
+    "grid": { "rows": 2, "columns": 2, "pattern": "independent" },
+    "coloraxis": {
+      "colorbar": {
+        "tickvals": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
+        "ticktext": [ 1, 22, 34, 5, 6, 77, 88, 99, 10101 ],
+        "len": 0.65,
+        "x": 1.05,
+        "xanchor": "left",
+        "y": 1.1,
+        "yanchor": "top"
+      }
+    },
+    "coloraxis2": {
+      "colorbar": {
+        "tickvals": [ 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 ],
+        "ticktext": [ 1, 22, 34, 5, 6, 77, 88, 99, 10101 ],
+        "len": 0.5,
+        "x": 1.05,
+        "xanchor": "left",
+        "y": -0.05,
+        "yanchor": "bottom"
+      }
+    },
+    "title": { "text": "Contour with Labels formatted using colorbar axis" },
+    "margin": { "b": 20, "t": 40 },
+    "width": 700,
+    "height": 450
+  }
+}