Skip to content

Issue198 #322

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 4 commits into from
Aug 8, 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
9 changes: 9 additions & 0 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ function validate(obj)
for n = 1:obj.State.Figure.NumAxes
try
updateAxis(obj,n);
catch
% TODO to the future
disp('warning: error in updateAxis')
end
end

Expand All @@ -635,6 +638,9 @@ function validate(obj)
obj.data{1, n}.opacity = 0.9;
obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)';
end
catch
% TODO to the future
disp('warning: error using update_opac')
end

end
Expand All @@ -643,6 +649,9 @@ function validate(obj)
for n = 1:obj.State.Figure.NumTexts
try
updateAnnotation(obj,n);
catch
% TODO to the future
disp('warning: error in updateAnnotation')
end
end

Expand Down
3 changes: 3 additions & 0 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
updateImage(obj, dataIndex);
case 'line'
updateLineseries(obj, dataIndex);
case 'categoricalhistogram'
updateCategoricalHistogram(obj, dataIndex);
case 'histogram'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateHistogramPolar(obj, dataIndex);
Expand Down Expand Up @@ -128,6 +130,7 @@
end
catch
% TODO to the future
disp('waring: error in updateData at AXIS/DATA CLEAN UP section')
end

%-------------------------------------------------------------------------%
Expand Down
145 changes: 145 additions & 0 deletions plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
function obj = updateCategoricalHistogram(obj,histIndex)

% x:...[DONE]
% y:...[DONE]
% histnorm:...[DONE]
% name:...[DONE]
% autobinx:...[DONE]
% nbinsx:...[DONE]
% xbins:...[DONE]
% autobiny:...[DONE]
% nbinsy:...[DONE]
% ybins:...[DONE]
% text:...[NOT SUPPORTED IN MATLAB]
% error_y:...[HANDLED BY ERRORBARSERIES]
% error_x:...[HANDLED BY ERRORBARSERIES]
% opacity: --- [TODO]
% xaxis:...[DONE]
% yaxis:...[DONE]
% showlegend:...[DONE]
% stream:...[HANDLED BY PLOTLYSTREAM]
% visible:...[DONE]
% type:...[DONE]
% orientation:...[DONE]

% MARKER:
% color: ...[DONE]
% size: ...[NA]
% symbol: ...[NA]
% opacity: ...[TODO]
% sizeref: ...[NA]
% sizemode: ...[NA]
% colorscale: ...[NA]
% cauto: ...[NA]
% cmin: ...[NA]
% cmax: ...[NA]
% outliercolor: ...[NA]
% maxdisplayed: ...[NA]

% MARKER LINE:
% color: ...[DONE]
% width: ...[DONE]
% dash: ...[NA]
% opacity: ...[TODO]
% shape: ...[NA]
% smoothing: ...[NA]
% outliercolor: ...[NA]
% outlierwidth: ...[NA]

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

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

%-HIST DATA STRUCTURE- %
hist_data = get(obj.State.Plot(histIndex).Handle);

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

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

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

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

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

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

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

%-bar type-%
obj.data{histIndex}.type = 'bar';

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

%-hist data-%
obj.data{histIndex}.width = hist_data.BarWidth;
obj.data{histIndex}.y = hist_data.BinCounts;

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

%-hist categorical layout on x-axis-%
obj.layout.xaxis1.type = 'category';
obj.layout.xaxis1.autotick = false;

gap = 1 - hist_data.BarWidth;
xmin = -0.5 * gap;
xmax = (hist_data.NumDisplayBins - 1) + 0.5 * gap;

obj.layout.xaxis1.range = {xmin, xmax};

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

%-hist name-%
obj.data{histIndex}.name = hist_data.DisplayName;

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

%-layout barmode-%
obj.layout.barmode = 'group';

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

%-hist line width-%
obj.data{histIndex}.marker.line.width = hist_data.LineWidth;

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

%-hist opacity-%
if ~ischar(hist_data.FaceAlpha)
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
end

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

obj.data{histIndex}.marker = extractPatchFace(hist_data);

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

%-hist visible-%
obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on');

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

%-hist showlegend-%
leg = get(hist_data.Annotation);
legInfo = get(leg.LegendInformation);

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

obj.data{histIndex}.showlegend = showleg;

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

end
4 changes: 2 additions & 2 deletions plotly/plotlyfig_aux/handlegraphics/updateLineseries.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ function updateLineseries(obj,plotIndex)
ispolar = true;
end

%-if polar ezplot or not-%
if abs(x(1)-x(end))<1e-5 && abs(y(1)-y(end))<1e-5
%-if ezpolar or not-%
if length(obj.State.Axis(plotIndex).Handle.Children) == 2
ispolar = true;
end

Expand Down
37 changes: 28 additions & 9 deletions plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
%-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) ';']);
Expand All @@ -35,7 +36,7 @@

%-surface x-%
obj.data{surfaceIndex}.x = image_data.XData;

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

%-surface y-%
Expand All @@ -46,6 +47,28 @@
%-surface z-%
obj.data{surfaceIndex}.z = image_data.ZData;

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

%- setting grid mesh by default -%
% x-direction
xmin = min(image_data.XData(:));
xmax = max(image_data.XData(:));
xsize = (xmax - xmin) / (size(image_data.XData, 2) - 1);
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(image_data.YData(:));
ymax = max(image_data.YData(:));
ysize = (ymax - ymin) / (size(image_data.YData, 2));
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';


else

Expand All @@ -61,22 +84,18 @@

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


%-image colorscale-%

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

for c = 1: length(cmap)
x1=(c-1)/length(cmap);
if x1 > 0.99
x=round(x1);
else
x=x1;
end
obj.data{surfaceIndex}.colorscale{c} = { x , ['rgb(' num2str(255*cmap(c,1)) ',' num2str(255*cmap(c,2)) ',' num2str(255*cmap(c,3)) ',' ')' ] };
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 = image_data.CData;

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

%-surface name-%
Expand Down