Skip to content

Commit ebaaca3

Browse files
committed
fix and test a bunch more contour edge cases
these edge cases literally involve strange things at the edges
1 parent f140629 commit ebaaca3

File tree

4 files changed

+108
-10
lines changed

4 files changed

+108
-10
lines changed

src/traces/contour/find_all_paths.js

-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ function makePath(pi, loc, edgeflag) {
8888
(marchStep[1] && (loc[1] < 0 || loc[1] > m - 2)),
8989
closedLoop = (locStr === startLocStr) && (marchStep.join(',') === startStepStr);
9090

91-
if(atEdge) pi.foundedge = true;
92-
9391
// have we completed a loop, or reached an edge?
9492
if((closedLoop) || (edgeflag && atEdge)) break;
9593

src/traces/contour/plot.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ function emptyPathinfo(contours, plotinfo, cd0) {
9595
// all unclosed paths (may have less items than starts,
9696
// if a path is closed by rounding)
9797
edgepaths: [],
98-
// we found some edges (even if they later got removed due to rounding)
99-
foundedge: false,
10098
// all closed paths
10199
paths: [],
102100
// store axes so we can convert to px
@@ -167,7 +165,8 @@ function makeFills(plotgroup, pathinfo, perimeter, contours) {
167165
}
168166

169167
function joinAllPaths(pi, perimeter) {
170-
var fullpath = (pi.foundedge || pi.z[0][0] < pi.level) ?
168+
var edgeVal2 = Math.min(pi.z[0][0], pi.z[0][1]),
169+
fullpath = (pi.edgepaths.length || edgeVal2 <= pi.level) ?
171170
'' : ('M' + perimeter.join('L') + 'Z'),
172171
i = 0,
173172
startsleft = pi.edgepaths.map(function(v, i) { return i; }),
36.9 KB
Loading
+106-5
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,132 @@
11
{
22
"data": [
33
{
4+
"x": [0, 5],
5+
"y": [0, 4],
46
"z": [[4, 3], [2, 1]],
57
"type": "contour",
68
"contours": {
79
"start": 1.1,
810
"end": 4.09,
911
"size": 1
1012
},
11-
"colorbar": {"x": 0.4}
13+
"colorbar": {"x": 0.4, "y": 0.9, "len": 0.2}
1214
},
1315
{
16+
"x": [0, 5],
17+
"y": [0, 4],
1418
"z": [[4, 3], [2, 1]],
1519
"type": "contour",
1620
"contours": {
1721
"start": 1,
1822
"end": 4,
1923
"size": 0.9999999
2024
},
21-
"colorbar": {"x": 1},
25+
"colorbar": {"x": 1, "y": 0.9, "len": 0.2},
2226
"xaxis": "x2"
27+
},
28+
{
29+
"z": [[0, 0, 0, 0, 0, 0],
30+
[0, 0, 9, 0, 0, 0],
31+
[0, 0, 0, 0, 0, 0],
32+
[0, 0, 0, -9, 0, 0],
33+
[0, 0, 0, 0, 0, 0]],
34+
"type": "contour",
35+
"contours": {
36+
"start": -0.000001,
37+
"end": 0.000001,
38+
"size": 0.000001
39+
},
40+
"colorbar": {"x": 0.4, "y": 0.65, "len": 0.2},
41+
"yaxis": "y2"
42+
},
43+
{
44+
"z": [[0, 0, 0, 0, 0, 0],
45+
[0, 0, 9, -9, 0, 0],
46+
[0, 0, 9, -9, 0, 0],
47+
[0, 0, 9, -9, 0, 0],
48+
[0, 0, 0, 0, 0, 0]],
49+
"type": "contour",
50+
"contours": {
51+
"start": -0.000001,
52+
"end": 0.000001,
53+
"size": 0.000001
54+
},
55+
"colorbar": {"x": 1, "y": 0.65, "len": 0.2},
56+
"xaxis": "x2",
57+
"yaxis": "y2"
58+
},
59+
{
60+
"z": [[0, 0, 0, 0, 0, 0],
61+
[0, 9, 0, 0, 0, 0],
62+
[0, 0, 0, 0, 0, 0],
63+
[0, 0, 0, 0, -9, 0],
64+
[0, 0, 0, 0, 0, 0]],
65+
"type": "contour",
66+
"contours": {
67+
"start": -0.000001,
68+
"end": 0.000001,
69+
"size": 0.000001
70+
},
71+
"colorbar": {"x": 0.4, "y": 0.4, "len": 0.2},
72+
"yaxis": "y3"
73+
},
74+
{
75+
"z": [[0, 0, 0, 0, 0, 0],
76+
[0, 0, -9, 0, 0, 0],
77+
[0, 0, 0, 0, 0, 0],
78+
[0, 0, 0, 9, 0, 0],
79+
[0, 0, 0, 0, 0, 0]],
80+
"type": "contour",
81+
"contours": {
82+
"start": -0.0000005,
83+
"end": 0.000001,
84+
"size": 0.000001
85+
},
86+
"colorbar": {"x": 1, "y": 0.4, "len": 0.2},
87+
"xaxis": "x2",
88+
"yaxis": "y3"
89+
},
90+
{
91+
"z": [[0, 0, 0, 0, 0, 0],
92+
[0, 9, 0, 0, 0, 0],
93+
[0, 0, 0, 0, 0, 0],
94+
[0, 0, 0, 0, -9, 0],
95+
[0, 0, 0, 0, 0, 0]],
96+
"type": "contour",
97+
"contours": {
98+
"start": -0.0000005,
99+
"end": 0.000001,
100+
"size": 0.000001
101+
},
102+
"colorbar": {"x": 0.4, "y": 0.15, "len": 0.2},
103+
"yaxis": "y4"
104+
},
105+
{
106+
"z": [[0, 0, 0, 0, 0, 0],
107+
[0, 0, 9, 0, 0, 0],
108+
[0, -9, -9, -9, -9, 0],
109+
[0, 0, 0, 9, 0, 0],
110+
[0, 0, 0, 0, 0, 0]],
111+
"type": "contour",
112+
"contours": {
113+
"start": -0.0000005,
114+
"end": 0.000001,
115+
"size": 0.000001
116+
},
117+
"colorbar": {"x": 1, "y": 0.15, "len": 0.2},
118+
"xaxis": "x2",
119+
"yaxis": "y4"
23120
}
24121
],
25122
"layout": {
26123
"xaxis": {"domain": [0, 0.4]},
27124
"xaxis2": {"domain": [0.6, 1]},
28-
"width": 800,
29-
"height": 400
125+
"yaxis": {"domain": [0.8, 1]},
126+
"yaxis2": {"domain": [0.55, 0.75]},
127+
"yaxis3": {"domain": [0.3, 0.5]},
128+
"yaxis4": {"domain": [0.05, 0.25]},
129+
"width": 600,
130+
"height": 800
30131
}
31-
}
132+
}

0 commit comments

Comments
 (0)