|  | 
|  | 1 | +function obj = updateContour3(obj,contourIndex) | 
|  | 2 | + | 
|  | 3 | + | 
|  | 4 | +%-FIGURE DATA STRUCTURE-% | 
|  | 5 | +figure_data = get(obj.State.Figure.Handle); | 
|  | 6 | + | 
|  | 7 | +%-AXIS INDEX-% | 
|  | 8 | +axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); | 
|  | 9 | + | 
|  | 10 | +%-AXIS DATA STRUCTURE-% | 
|  | 11 | +axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); | 
|  | 12 | + | 
|  | 13 | +%-PLOT DATA STRUCTURE- % | 
|  | 14 | +contour_data = get(obj.State.Plot(contourIndex).Handle); | 
|  | 15 | + | 
|  | 16 | +%-CHECK FOR MULTIPLE AXES-% | 
|  | 17 | +[xsource, ysource] = findSourceAxis(obj,axIndex); | 
|  | 18 | + | 
|  | 19 | +%-AXIS DATA-% | 
|  | 20 | +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); | 
|  | 21 | +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); | 
|  | 22 | + | 
|  | 23 | +%-------------------------------------------------------------------------% | 
|  | 24 | + | 
|  | 25 | +%-contour xaxis-% | 
|  | 26 | +obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; | 
|  | 27 | + | 
|  | 28 | +%-------------------------------------------------------------------------% | 
|  | 29 | + | 
|  | 30 | +%-contour yaxis-% | 
|  | 31 | +obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; | 
|  | 32 | + | 
|  | 33 | +%-------------------------------------------------------------------------% | 
|  | 34 | + | 
|  | 35 | +%-contour name-% | 
|  | 36 | +obj.data{contourIndex}.name = contour_data.DisplayName; | 
|  | 37 | + | 
|  | 38 | +%-------------------------------------------------------------------------% | 
|  | 39 | + | 
|  | 40 | +%-setting the plot-% | 
|  | 41 | +xdata = contour_data.XData; | 
|  | 42 | +ydata = contour_data.YData; | 
|  | 43 | +zdata = contour_data.ZData; | 
|  | 44 | +     | 
|  | 45 | +%---------------------------------------------------------------------% | 
|  | 46 | + | 
|  | 47 | +%-contour type-% | 
|  | 48 | +obj.data{contourIndex}.type = 'surface'; | 
|  | 49 | + | 
|  | 50 | +%---------------------------------------------------------------------% | 
|  | 51 | + | 
|  | 52 | +%-contour x and y data | 
|  | 53 | +if isvector(xdata) | 
|  | 54 | +    [xdata, ydata] = meshgrid(xdata, ydata); | 
|  | 55 | +end | 
|  | 56 | +obj.data{contourIndex}.x = xdata; | 
|  | 57 | +obj.data{contourIndex}.y = ydata; | 
|  | 58 | + | 
|  | 59 | +%---------------------------------------------------------------------% | 
|  | 60 | + | 
|  | 61 | +%-contour z data-% | 
|  | 62 | +obj.data{contourIndex}.z = zdata; | 
|  | 63 | + | 
|  | 64 | +%---------------------------------------------------------------------% | 
|  | 65 | + | 
|  | 66 | +%-setting for contour lines z-direction-% | 
|  | 67 | +if length(contour_data.LevelList) > 1 | 
|  | 68 | +    zstart = contour_data.LevelList(1); | 
|  | 69 | +    zend = contour_data.LevelList(end); | 
|  | 70 | +    zsize = mean(diff(contour_data.LevelList)); | 
|  | 71 | +else | 
|  | 72 | +    zstart = contour_data.LevelList(1) - 1e-3; | 
|  | 73 | +    zend = contour_data.LevelList(end) + 1e-3; | 
|  | 74 | +    zsize = 2e-3; | 
|  | 75 | +end | 
|  | 76 | + | 
|  | 77 | +obj.data{contourIndex}.contours.z.start = zstart; | 
|  | 78 | +obj.data{contourIndex}.contours.z.end = zend; | 
|  | 79 | +obj.data{contourIndex}.contours.z.size = zsize; | 
|  | 80 | +obj.data{contourIndex}.contours.z.show = true; | 
|  | 81 | +obj.data{contourIndex}.contours.z.usecolormap = true; | 
|  | 82 | +obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth; | 
|  | 83 | +obj.data{contourIndex}.hidesurface = true; | 
|  | 84 | + | 
|  | 85 | +%---------------------------------------------------------------------% | 
|  | 86 | + | 
|  | 87 | +%-colorscale-% | 
|  | 88 | +colormap = figure_data.Colormap; | 
|  | 89 | + | 
|  | 90 | +for c = 1:size((colormap),1) | 
|  | 91 | +    col =  255*(colormap(c,:)); | 
|  | 92 | +    obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; | 
|  | 93 | +end | 
|  | 94 | + | 
|  | 95 | +%---------------------------------------------------------------------% | 
|  | 96 | + | 
|  | 97 | +%-aspect ratio-% | 
|  | 98 | +ar = obj.PlotOptions.AspectRatio; | 
|  | 99 | + | 
|  | 100 | +if ~isempty(ar) | 
|  | 101 | +    if ischar(ar) | 
|  | 102 | +        obj.layout.scene.aspectmode = ar; | 
|  | 103 | +    elseif isvector(ar) && length(ar) == 3 | 
|  | 104 | +        xar = ar(1); | 
|  | 105 | +        yar = ar(2); | 
|  | 106 | +        zar = ar(3); | 
|  | 107 | +    end | 
|  | 108 | +else | 
|  | 109 | + | 
|  | 110 | +    %-define as default-% | 
|  | 111 | +    xar = max(xdata(:)); | 
|  | 112 | +    yar = max(ydata(:)); | 
|  | 113 | +    zar = 0.7*max([xar, yar]); | 
|  | 114 | +end | 
|  | 115 | + | 
|  | 116 | +obj.layout.scene.aspectratio.x = xar; | 
|  | 117 | +obj.layout.scene.aspectratio.y = yar; | 
|  | 118 | +obj.layout.scene.aspectratio.z = zar; | 
|  | 119 | + | 
|  | 120 | +%---------------------------------------------------------------------% | 
|  | 121 | + | 
|  | 122 | +%-camera eye-% | 
|  | 123 | +ey = obj.PlotOptions.CameraEye; | 
|  | 124 | + | 
|  | 125 | +if ~isempty(ey) | 
|  | 126 | +    if isvector(ey) && length(ey) == 3 | 
|  | 127 | +        obj.layout.scene.camera.eye.x = ey(1); | 
|  | 128 | +        obj.layout.scene.camera.eye.y = ey(2); | 
|  | 129 | +        obj.layout.scene.camera.eye.z = ey(3); | 
|  | 130 | +    end | 
|  | 131 | +else | 
|  | 132 | + | 
|  | 133 | +    %-define as default-% | 
|  | 134 | +    xey = min(xdata(:)); if xey>0 xfac = -0.2; else xfac = 0.2; end | 
|  | 135 | +    yey = min(ydata(:)); if yey>0 yfac = -0.2; else yfac = 0.2; end | 
|  | 136 | +    if zar>0 zfac = -0.15; else zfac = 0.15; end | 
|  | 137 | + | 
|  | 138 | +    obj.layout.scene.camera.eye.x = xey + xfac*xey; | 
|  | 139 | +    obj.layout.scene.camera.eye.y = yey + yfac*yey; | 
|  | 140 | +    obj.layout.scene.camera.eye.z = zar + yfac*zar; | 
|  | 141 | +end | 
|  | 142 | + | 
|  | 143 | +%---------------------------------------------------------------------% | 
|  | 144 | + | 
|  | 145 | +%-zerolines hidded-% | 
|  | 146 | +obj.layout.scene.xaxis.zeroline = false; | 
|  | 147 | +obj.layout.scene.yaxis.zeroline = false; | 
|  | 148 | +obj.layout.scene.zaxis.zeroline = false; | 
|  | 149 | + | 
|  | 150 | +%-------------------------------------------------------------------------% | 
|  | 151 | + | 
|  | 152 | +%-contour visible-% | 
|  | 153 | +obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); | 
|  | 154 | + | 
|  | 155 | +%-------------------------------------------------------------------------% | 
|  | 156 | + | 
|  | 157 | +%-contour showscale-% | 
|  | 158 | +obj.data{contourIndex}.showscale = false; | 
|  | 159 | + | 
|  | 160 | +%-------------------------------------------------------------------------% | 
|  | 161 | + | 
|  | 162 | +%-contour reverse scale-% | 
|  | 163 | +obj.data{contourIndex}.reversescale = false; | 
|  | 164 | + | 
|  | 165 | +%-------------------------------------------------------------------------% | 
|  | 166 | + | 
|  | 167 | +%-contour showlegend-% | 
|  | 168 | + | 
|  | 169 | +leg = get(contour_data.Annotation); | 
|  | 170 | +legInfo = get(leg.LegendInformation); | 
|  | 171 | + | 
|  | 172 | +switch legInfo.IconDisplayStyle | 
|  | 173 | +    case 'on' | 
|  | 174 | +        showleg = true; | 
|  | 175 | +    case 'off' | 
|  | 176 | +        showleg = false; | 
|  | 177 | +end | 
|  | 178 | + | 
|  | 179 | +obj.data{contourIndex}.showlegend = showleg; | 
|  | 180 | + | 
|  | 181 | +%-------------------------------------------------------------------------% | 
|  | 182 | + | 
|  | 183 | +end | 
0 commit comments