Skip to content

Commit eab32b3

Browse files
committed
match horizontal colorbar.y with vertical
1 parent 00987c5 commit eab32b3

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

src/components/colorbar/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = overrideAll({
8888
max: 3,
8989
description: [
9090
'Sets the y position of the color bar (in plot fraction).',
91-
'Defaults to -0.02 when `orientation` if *v* and ',
91+
'Defaults to 1.02 when `orientation` if *v* and ',
9292
'defaults to 0.5 when `orientation` if *h*.'
9393
].join(' ')
9494
},

src/components/colorbar/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
4040
coerce('x', isVertical ? 1.02 : 0.5);
4141
coerce('xanchor', isVertical ? 'left' : 'center');
4242
coerce('xpad');
43-
coerce('y', isVertical ? 0.5 : -0.02);
43+
coerce('y', isVertical ? 0.5 : 1.02);
4444
coerce('yanchor', isVertical ? 'middle' : 'bottom');
4545
coerce('ypad');
4646
Lib.noneOrAll(colorbarIn, colorbarOut, ['x', 'y']);

src/components/colorbar/draw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function makeColorBarData(gd) {
167167
}
168168

169169
function drawColorBar(g, opts, gd) {
170+
var isVertical = opts.orientation === 'v';
170171
var len = opts.len;
171172
var lenmode = opts.lenmode;
172173
var thickness = opts.thickness;
@@ -178,7 +179,7 @@ function drawColorBar(g, opts, gd) {
178179
var xpad = opts.xpad;
179180
var ypad = opts.ypad;
180181
var optsX = opts.x;
181-
var optsY = opts.y;
182+
var optsY = isVertical ? opts.y : 1 - opts.y;
182183

183184
var fullLayout = gd._fullLayout;
184185
var gs = fullLayout._size;
@@ -209,7 +210,6 @@ function drawColorBar(g, opts, gd) {
209210
// when the colorbar itself is pushing the margins.
210211
// but then the fractional size is calculated based on the
211212
// actual graph size, so that the axes will size correctly.
212-
var isVertical = opts.orientation === 'v';
213213
var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? (isVertical ? gs.w : gs.h) : 1));
214214
var thickFrac = thickPx / (isVertical ? gs.w : gs.h);
215215
var lenPx = Math.round(len * (lenmode === 'fraction' ? (isVertical ? gs.h : gs.w) : 1));

test/image/mocks/z_h-colorbar02.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"showscale": true,
1212
"colorbar": {
1313
"orientation": "h",
14-
"y": 1.1,
14+
"y": -0.1,
1515
"yanchor": "top",
1616
"thickness": 20,
1717
"ticks": "inside",

test/image/mocks/z_h-colorbar05.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"orientation": "h",
1414
"xanchor": "right",
1515
"x": 1,
16-
"y": 1.02,
16+
"y": -0.02,
1717
"yanchor": "top",
1818
"thickness": 20,
1919
"len": 0.5,

test/image/mocks/z_h-colorbar08.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"colorbar": {
1313
"orientation": "h",
1414
"yanchor": "top",
15-
"y": 1.5,
15+
"y": -0.5,
1616
"xanchor": "right",
1717
"x": 1,
1818
"thickness": 10,

test/image/mocks/z_h-colorbar_airfoil.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
"colorbar":{
219219
"orientation": "h",
220220
"x":0.75,
221-
"y":1.1,
221+
"y":-0.1,
222222
"yanchor":"top",
223223
"len":0.5,
224224
"title":{

test/plot-schema.json

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)