|
1 | 1 | function obj = updateHistogram2(obj,histIndex)
|
2 | 2 |
|
| 3 | +%---------------------------------------------------------------------% |
| 4 | + |
3 | 5 | %-AXIS INDEX-%
|
4 | 6 | axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis);
|
5 | 7 |
|
| 8 | +%---------------------------------------------------------------------% |
| 9 | + |
6 | 10 | %-HIST DATA STRUCTURE- %
|
7 | 11 | hist_data = get(obj.State.Plot(histIndex).Handle);
|
8 | 12 |
|
| 13 | +%---------------------------------------------------------------------% |
| 14 | + |
9 | 15 | %-hist type-%
|
10 | 16 | obj.data{histIndex}.type = 'mesh3d';
|
11 | 17 |
|
| 18 | +%---------------------------------------------------------------------% |
| 19 | + |
12 | 20 | %-required parameters-%
|
13 | 21 | values = hist_data.Values;
|
14 |
| -xedges = hist_data.XBinEdges; |
| 22 | +xedges = hist_data.XBinEdges; |
15 | 23 | yedges = hist_data.YBinEdges;
|
16 | 24 |
|
| 25 | +sx = diff(xedges(2:end-1)); |
| 26 | +sy = diff(yedges(2:end-1)); |
| 27 | + |
| 28 | +if isinf(xedges(1)) xedges(1) = xedges(2) - sx(1); end |
| 29 | +if isinf(yedges(1)) yedges(1) = yedges(2) - sy(1); end |
| 30 | + |
| 31 | +if isinf(xedges(end)) xedges(end) = xedges(end-1) + sx(1); end |
| 32 | +if isinf(yedges(end)) yedges(end) = yedges(end-1) + sy(1); end |
| 33 | + |
| 34 | +%---------------------------------------------------------------------% |
| 35 | + |
17 | 36 | %-get the values to use plotly's mesh3D-%
|
18 |
| -bargap = 0.06; |
| 37 | +bargap = 0.05; |
19 | 38 | [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap);
|
20 | 39 |
|
| 40 | +%---------------------------------------------------------------------% |
| 41 | + |
21 | 42 | %-passing parameters to mesh3D-%
|
22 | 43 | obj.data{histIndex}.x = X;
|
23 | 44 | obj.data{histIndex}.y = Y;
|
24 | 45 | obj.data{histIndex}.z = Z;
|
25 |
| -obj.data{histIndex}.i = uint16(I-1); |
26 |
| -obj.data{histIndex}.j = uint16(J-1); |
27 |
| -obj.data{histIndex}.k = uint16(K-1); |
| 46 | +obj.data{histIndex}.i = int16(I-1); |
| 47 | +obj.data{histIndex}.j = int16(J-1); |
| 48 | +obj.data{histIndex}.k = int16(K-1); |
| 49 | + |
| 50 | +%---------------------------------------------------------------------% |
28 | 51 |
|
29 | 52 | %-some settings-%
|
30 |
| -obj.data{histIndex}.color=[0.8,0.8,0.8]; |
| 53 | +% obj.data{histIndex}.color='rgb(0,255,0)'; |
31 | 54 | obj.data{histIndex}.contour.show = true;
|
32 |
| -obj.data{histIndex}.contour.color = 'black'; |
33 | 55 | obj.data{histIndex}.contour.width = 6;
|
| 56 | +obj.data{histIndex}.contour.color='rgb(0,0,0)'; |
34 | 57 | obj.data{histIndex}.flatshading = true;
|
35 |
| -obj.data{histIndex}.bordercolor = 'black'; |
36 |
| -obj.data{histIndex}.borderwidth = 6; |
| 58 | + |
| 59 | +%---------------------------------------------------------------------% |
| 60 | + |
| 61 | +%-lighting settings-% |
| 62 | +obj.data{histIndex}.lighting.diffuse = 0.92; |
| 63 | +obj.data{histIndex}.lighting.ambient = 0.54; |
| 64 | +obj.data{histIndex}.lighting.specular = 1.42; |
| 65 | +obj.data{histIndex}.lighting.roughness = 0.52; |
| 66 | +obj.data{histIndex}.lighting.fresnel = 0.2; |
| 67 | +obj.data{histIndex}.lighting.vertexnormalsepsilon = 1e-12; |
| 68 | +obj.data{histIndex}.lighting.facenormalsepsilon = 1e-6; |
| 69 | + |
| 70 | +%---------------------------------------------------------------------% |
| 71 | + |
| 72 | +%-aspect ratio-% |
| 73 | +ar = obj.PlotOptions.AspectRatio; |
| 74 | + |
| 75 | +if ~isempty(ar) |
| 76 | + if ischar(ar) |
| 77 | + obj.layout.scene.aspectmode = ar; |
| 78 | + elseif isvector(ar) && length(ar) == 3 |
| 79 | + xar = ar(1); |
| 80 | + yar = ar(2); |
| 81 | + zar = ar(3); |
| 82 | + end |
| 83 | +else |
| 84 | + |
| 85 | + %-define as default-% |
| 86 | + xar = max(xedges(:)); |
| 87 | + yar = max(yedges(:)); |
| 88 | + zar = 0.7*max([xar, yar]); |
| 89 | +end |
| 90 | + |
| 91 | +obj.layout.scene.aspectratio.x = xar; |
| 92 | +obj.layout.scene.aspectratio.y = yar; |
| 93 | +obj.layout.scene.aspectratio.z = zar; |
| 94 | + |
| 95 | +%---------------------------------------------------------------------% |
| 96 | + |
| 97 | +%-camera eye-% |
| 98 | +ey = obj.PlotOptions.CameraEye; |
| 99 | + |
| 100 | +if ~isempty(ey) |
| 101 | + if isvector(ey) && length(ey) == 3 |
| 102 | + obj.layout.scene.camera.eye.x = ey(1); |
| 103 | + obj.layout.scene.camera.eye.y = ey(2); |
| 104 | + obj.layout.scene.camera.eye.z = ey(3); |
| 105 | + end |
| 106 | +else |
| 107 | + |
| 108 | + %-define as default-% |
| 109 | + xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end |
| 110 | + yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end |
| 111 | + if zar>0 zfac = 0.2; else zfac = -0.2; end |
| 112 | + |
| 113 | + obj.layout.scene.camera.eye.x = xey + xfac*xey; |
| 114 | + obj.layout.scene.camera.eye.y = yey + yfac*yey; |
| 115 | + obj.layout.scene.camera.eye.z = zar + zfac*zar; |
| 116 | +end |
| 117 | + |
| 118 | +%---------------------------------------------------------------------% |
| 119 | + |
| 120 | + |
| 121 | +%-zerolines hidded-% |
| 122 | +obj.layout.scene.xaxis.zeroline = false; |
| 123 | +obj.layout.scene.yaxis.zeroline = false; |
| 124 | +obj.layout.scene.zaxis.zeroline = false; |
| 125 | + |
| 126 | +%---------------------------------------------------------------------% |
37 | 127 |
|
38 | 128 | %-layout bargap-%
|
39 | 129 | obj.layout.bargap = bargap;
|
40 | 130 |
|
41 |
| -%-layout barmode-% |
42 |
| -obj.layout.barmode = 'group'; |
43 |
| - |
44 | 131 | %-hist name-%
|
45 | 132 | obj.data{histIndex}.name = hist_data.DisplayName;
|
46 | 133 |
|
47 | 134 | %-hist visible-%
|
48 | 135 | obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on');
|
49 | 136 |
|
| 137 | +%---------------------------------------------------------------------% |
| 138 | + |
50 | 139 | end
|
51 | 140 |
|
52 | 141 |
|
|
131 | 220 | ze = zeros(size(xe));
|
132 | 221 |
|
133 | 222 | positions = zeros([size(xe), 3]);
|
134 |
| - positions(:,:,1) = ye'; |
135 |
| - positions(:,:,2) = xe'; |
136 |
| - positions(:,:,3) = ze'; |
| 223 | + positions(:,:,1) = xe; |
| 224 | + positions(:,:,2) = ye; |
| 225 | + positions(:,:,3) = ze; |
137 | 226 |
|
138 | 227 | [m, n, p] = size(positions);
|
139 | 228 | positions = reshape(positions, [m*n, p]);
|
|
0 commit comments