Skip to content

Commit 2885f23

Browse files
authored
Merge pull request #3983 from plotly/fix-box-categoryorder
Fix boxplot with categoryorder
2 parents fef1c60 + cb6249a commit 2885f23

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

src/plots/plots.js

+3
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,9 @@ plots.doCalcdata = function(gd, traces) {
28872887
// Sort axis categories per value if specified
28882888
var sorted = sortAxisCategoriesByValue(axList, gd);
28892889
if(sorted.length) {
2890+
// how many box/violins plots do we have (in case they're grouped)
2891+
fullLayout._numBoxes = 0;
2892+
fullLayout._numViolins = 0;
28902893
// If a sort operation was performed, run calc() again
28912894
for(i = 0; i < sorted.length; i++) calci(sorted[i], true);
28922895
for(i = 0; i < sorted.length; i++) calci(sorted[i], false);
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"data":[
3+
{
4+
"y":[
5+
0.2,
6+
0.2,
7+
0.6,
8+
1,
9+
0.5,
10+
0.4,
11+
0.2,
12+
0.7,
13+
0.9,
14+
0.1,
15+
0.5,
16+
0.3
17+
],
18+
"x":[
19+
"day 1",
20+
"day 1",
21+
"day 1",
22+
"day 1",
23+
"day 1",
24+
"day 1",
25+
"day 2",
26+
"day 2",
27+
"day 2",
28+
"day 2",
29+
"day 2",
30+
"day 2"
31+
],
32+
"name":"kale",
33+
"marker":{
34+
"color":"#3D9970"
35+
},
36+
"type":"box"
37+
},
38+
{
39+
"y":[
40+
0.6,
41+
0.7,
42+
0.3,
43+
0.6,
44+
0,
45+
0.5,
46+
0.7,
47+
0.9,
48+
0.5,
49+
0.8,
50+
0.7,
51+
0.2
52+
],
53+
"x":[
54+
"day 1",
55+
"day 1",
56+
"day 1",
57+
"day 1",
58+
"day 1",
59+
"day 1",
60+
"day 2",
61+
"day 2",
62+
"day 2",
63+
"day 2",
64+
"day 2",
65+
"day 2"
66+
],
67+
"name":"radishes",
68+
"marker":{
69+
"color":"#FF4136"
70+
},
71+
"type":"box"
72+
},
73+
{
74+
"y":[
75+
0.1,
76+
0.3,
77+
0.1,
78+
0.9,
79+
0.6,
80+
0.6,
81+
0.9,
82+
1,
83+
0.3,
84+
0.6,
85+
0.8,
86+
0.5
87+
],
88+
"x":[
89+
"day 1",
90+
"day 1",
91+
"day 1",
92+
"day 1",
93+
"day 1",
94+
"day 1",
95+
"day 2",
96+
"day 2",
97+
"day 2",
98+
"day 2",
99+
"day 2",
100+
"day 2"
101+
],
102+
"name":"carrots",
103+
"marker":{
104+
"color":"#FF851B"
105+
},
106+
"type":"box"
107+
}
108+
],
109+
"layout":{
110+
"xaxis": {
111+
"categoryorder": "mean descending"
112+
},
113+
"yaxis":{
114+
"zeroline":false,
115+
"title":"normalized moisture"
116+
},
117+
"boxmode":"group"
118+
}
119+
}

0 commit comments

Comments
 (0)