Skip to content

Commit 48758d8

Browse files
committed
fixup scalemode 'count' calculation
1 parent 14bded3 commit 48758d8

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/traces/violin/plot.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports = function plot(gd, plotinfo, cd) {
8080
scale = groupStats.maxWidth / bdPos;
8181
break;
8282
case 'count':
83-
scale = (groupStats.maxWidth / bdPos) * (groupStats.maxCount / len);
83+
scale = (groupStats.maxWidth / bdPos) * (groupStats.maxCount / d.pts.length);
8484
break;
8585
}
8686

@@ -133,7 +133,6 @@ module.exports = function plot(gd, plotinfo, cd) {
133133
d.posDensityScale = scale * bdPos;
134134
d.path = pathSel.node();
135135
d.pathLength = d.path.getTotalLength() / (hasBothSides ? 2 : 1);
136-
137136
});
138137

139138
if(trace.showinnerbox) {
-1.68 KB
Loading

test/image/mocks/violin_side-by-side.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
"legend": {
1010
"tracegroupgap": 0
1111
},
12-
"violingap": 0.05,
12+
"violingap": 0,
1313
"violingroupgap": 0,
1414
"violinmode": "overlay",
1515
"height": 700
1616
},
1717
"data": [
1818
{
19+
"text": "sample length: 32",
20+
"hoveron": "points+kde",
1921
"legendgroup": "F",
2022
"scalegroup": "F",
2123
"points": "all",
@@ -77,6 +79,8 @@
7779
"orientation": "h"
7880
},
7981
{
82+
"text": "sample length: 30",
83+
"hoveron": "points+kde",
8084
"legendgroup": "M",
8185
"scalegroup": "M",
8286
"points": "all",
@@ -136,6 +140,8 @@
136140
"orientation": "h"
137141
},
138142
{
143+
"text": "sample length: 9",
144+
"hoveron": "points+kde",
139145
"legendgroup": "F",
140146
"scalegroup": "F",
141147
"points": "all",
@@ -174,6 +180,8 @@
174180
"orientation": "h"
175181
},
176182
{
183+
"text": "sample length: 10",
184+
"hoveron": "points+kde",
177185
"legendgroup": "M",
178186
"scalegroup": "M",
179187
"points": "all",
@@ -213,6 +221,8 @@
213221
"orientation": "h"
214222
},
215223
{
224+
"text": "sample length: 28",
225+
"hoveron": "points+kde",
216226
"legendgroup": "F",
217227
"scalegroup": "F",
218228
"points": "all",
@@ -270,6 +280,8 @@
270280
"orientation": "h"
271281
},
272282
{
283+
"text": "sample length: 59",
284+
"hoveron": "points+kde",
273285
"legendgroup": "M",
274286
"scalegroup": "M",
275287
"points": "all",
@@ -358,6 +370,8 @@
358370
"orientation": "h"
359371
},
360372
{
373+
"text": "sample length: 18",
374+
"hoveron": "points+kde",
361375
"legendgroup": "F",
362376
"scalegroup": "F",
363377
"points": "all",
@@ -405,6 +419,8 @@
405419
"orientation": "h"
406420
},
407421
{
422+
"text": "sample length: 58",
423+
"hoveron": "points+kde",
408424
"legendgroup": "M",
409425
"scalegroup": "M",
410426
"points": "all",

0 commit comments

Comments
 (0)