Skip to content

Commit 7a3af9c

Browse files
authored
Merge pull request #4314 from plotly/fix-box-shift-vertical-one-sided-violins
Fix box/meanline offset for one-sided vertical violins
2 parents bae6c5f + 27d5957 commit 7a3af9c

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

src/traces/violin/plot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
139139
bPosPxOffset = 0;
140140
} else if(hasPositiveSide) {
141141
bdPosScaled = [0, bdPos * boxWidth / 2];
142-
bPosPxOffset = -boxLineWidth;
142+
bPosPxOffset = boxLineWidth * {x: 1, y: -1}[t.posLetter];
143143
} else {
144144
bdPosScaled = [bdPos * boxWidth / 2, 0];
145-
bPosPxOffset = boxLineWidth;
145+
bPosPxOffset = boxLineWidth * {x: -1, y: 1}[t.posLetter];
146146
}
147147

148148
// inner box
-31 Bytes
Loading
26 KB
Loading
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"data": [
3+
{
4+
"type": "violin",
5+
"x0": 10,
6+
"y": [ 1, 1, 2, 2, 3, 3, 4, 4 ],
7+
"box": { "visible": true },
8+
"meanline": { "visible": true },
9+
"side": "positive"
10+
},
11+
{
12+
"type": "violin",
13+
"x0": 100,
14+
"y": [ 1, 1, 2, 2, 3, 3, 4, 4 ],
15+
"box": { "visible": true },
16+
"meanline": { "visible": true },
17+
"side": "negative"
18+
},
19+
{
20+
"type": "violin",
21+
"y0": 10,
22+
"x": [ 1, 1, 2, 2, 3, 3, 4, 4 ],
23+
"box": { "visible": true },
24+
"meanline": { "visible": true },
25+
"side": "positive",
26+
"xaxis": "x2",
27+
"yaxis": "y2"
28+
},
29+
{
30+
"type": "violin",
31+
"y0": 100,
32+
"x": [ 1, 1, 2, 2, 3, 3, 4, 4 ],
33+
"box": { "visible": true },
34+
"meanline": { "visible": true },
35+
"side": "negative",
36+
"xaxis": "x2",
37+
"yaxis": "y2"
38+
}
39+
],
40+
"layout": {
41+
"xaxis": {
42+
"ticks": "inside"
43+
},
44+
"yaxis2": {
45+
"ticks": "inside"
46+
},
47+
"showlegend": false,
48+
"grid": {
49+
"columns": 2,
50+
"rows": 1,
51+
"pattern": "independent"
52+
},
53+
"width": 500,
54+
"hieght": 500,
55+
"margin": {
56+
"t": 40,
57+
"l": 40,
58+
"r": 40,
59+
"b": 40
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)