Skip to content

Issue283 #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);
case 'functionsurface'
updateFunctionSurface(obj,dataIndex);

%-GROUP PLOT OBJECTS-%
case 'area'
Expand Down
118 changes: 118 additions & 0 deletions plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
function obj = updateFunctionSurface(obj, surfaceIndex)

%-AXIS INDEX-%
axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis);

%-CHECK FOR MULTIPLE AXES-%
[xsource, ysource] = findSourceAxis(obj,axIndex);

%-SURFACE DATA STRUCTURE- %
image_data = get(obj.State.Plot(surfaceIndex).Handle);
figure_data = get(obj.State.Figure.Handle);

%-AXIS DATA-%
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);

%-------------------------------------------------------------------------%

%-surface xaxis-%
obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)];

%-------------------------------------------------------------------------%

%-surface yaxis-%
obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)];

%-------------------------------------------------------------------------%

%-surface type-%
obj.data{surfaceIndex}.type = 'surface';

%---------------------------------------------------------------------%

%-surface x-%
mden = image_data.MeshDensity;
x = reshape(image_data.XData(1:mden*mden), [mden, mden]);
obj.data{surfaceIndex}.x = x;

%---------------------------------------------------------------------%

%-surface y-%
y = reshape(image_data.YData(1:mden*mden), [mden, mden]);
obj.data{surfaceIndex}.y = y;

%---------------------------------------------------------------------%

%-surface z-%
z = reshape(image_data.ZData(1:mden*mden), [mden, mden]);
obj.data{surfaceIndex}.z = z;

%---------------------------------------------------------------------%

%- setting grid mesh by default -%
% x-direction
xmin = min(x(:));
xmax = max(x(:));
xsize = (xmax - xmin) / mden;
obj.data{surfaceIndex}.contours.x.start = xmin;
obj.data{surfaceIndex}.contours.x.end = xmax;
obj.data{surfaceIndex}.contours.x.size = xsize;
obj.data{surfaceIndex}.contours.x.show = true;
obj.data{surfaceIndex}.contours.x.color = 'black';
% y-direction
ymin = min(y(:));
ymax = max(y(:));
ysize = (ymax - ymin) / mden;
obj.data{surfaceIndex}.contours.y.start = ymin;
obj.data{surfaceIndex}.contours.y.end = ymax;
obj.data{surfaceIndex}.contours.y.size = ysize;
obj.data{surfaceIndex}.contours.y.show = true;
obj.data{surfaceIndex}.contours.y.color = 'black';

%-------------------------------------------------------------------------%

%-image colorscale-%

cmap = figure_data.Colormap;
len = length(cmap)-1;

for c = 1: length(cmap)
col = 255 * cmap(c, :);
obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] };
end

obj.data{surfaceIndex}.surfacecolor = z;

%-------------------------------------------------------------------------%

%-surface name-%
obj.data{surfaceIndex}.name = image_data.DisplayName;

%-------------------------------------------------------------------------%

%-surface showscale-%
obj.data{surfaceIndex}.showscale = false;

%-------------------------------------------------------------------------%

%-surface visible-%
obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on');

%-------------------------------------------------------------------------%

leg = get(image_data.Annotation);
legInfo = get(leg.LegendInformation);

switch legInfo.IconDisplayStyle
case 'on'
showleg = true;
case 'off'
showleg = false;
end

obj.data{surfaceIndex}.showlegend = showleg;

%-------------------------------------------------------------------------%

end
34 changes: 24 additions & 10 deletions plotly/plotlyfig_aux/handlegraphics/updateImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,36 @@
%-------------------------------------------------------------------------%

%-image x-%
x = image_data.XData;
cdata = image_data.CData;

if (size(image_data.XData,2) == 2)
obj.data{imageIndex}.x = image_data.XData(1):image_data.XData(2);
obj.data{imageIndex}.x = linspace(x(1), x(2), size(cdata,2));
else
obj.data{imageIndex}.x = image_data.XData;
end

%-------------------------------------------------------------------------%

%-image y-%
y = image_data.YData;

if (size(image_data.YData,2) == 2)
obj.data{imageIndex}.y = image_data.YData(1):image_data.YData(2);
obj.data{imageIndex}.y = linspace(y(1), y(2), size(cdata,1));
else
obj.data{imageIndex}.y = image_data.YData;
obj.data{imageIndex}.y = y;
end

%-------------------------------------------------------------------------%

%-image z-%
if(size(image_data.CData,3) > 1)
% TODO: ALLOW FOR TRUE COLOUR SPECS.
obj.data{imageIndex}.z = image_data.CData(:,:,1);
isrgbimg = (size(image_data.CData,3) > 1);

if isrgbimg
[IND,colormap] = rgb2ind(cdata, 256);
obj.data{imageIndex}.z = IND;
else
obj.data{imageIndex}.z = image_data.CData;
obj.data{imageIndex}.z = cdata;
end

%-------------------------------------------------------------------------%
Expand Down Expand Up @@ -121,15 +128,22 @@
%-------------------------------------------------------------------------%

%-image zmax-%
axis_data.CLim(2);
% obj.data{imageIndex}.zmax = 255; % comment this as optional
if ~strcmpi(image_data.CDataMapping, 'direct')
obj.data{imageIndex}.zmax = axis_data.CLim(2);
else
obj.data{imageIndex}.zmax = 255;
end

%-------------------------------------------------------------------------%

%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-%

%-image colorscale-%
colormap = figure_data.Colormap;

if ~isrgbimg
colormap = figure_data.Colormap;
end

len = length(colormap) - 1;

for c = 1:size(colormap, 1)
Expand Down
5 changes: 4 additions & 1 deletion plotly/plotlyfig_aux/handlegraphics/updateLineseries.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ function updateLineseries(obj,plotIndex)
%-------------------------------------------------------------------------%

if isfield(plot_data,'ZData')
if any(plot_data.ZData)

numbset = unique(plot_data.ZData);

if any(plot_data.ZData) && length(numbset)>1
%-scatter z-%
obj.data{plotIndex}.z = plot_data.ZData;

Expand Down