diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 3c633248..7e5801a6 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -945,7 +945,7 @@ function delete(obj) if ~( ... strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ... || strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ... - || strcmpi(fieldname,'scatterpolar') ... + || strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ... ) fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']); end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index a04fe549..23d78825 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -1,146 +1,135 @@ -%----UPDATE PLOT DATA/STYLE----% - -function obj = updateData(obj, dataIndex) - -%-update plot based on plot call class-% -try - - switch lower(obj.State.Plot(dataIndex).Class) - - %--CORE PLOT OBJECTS--% - case 'image' - updateImage(obj, dataIndex); - case 'line' - updateLineseries(obj, dataIndex); - case 'histogram' - updateHistogram(obj, dataIndex); - case 'histogram2' - updateHistogram2(obj, dataIndex); - case 'patch' - % check for histogram - if isHistogram(obj,dataIndex) - updateHistogram(obj,dataIndex); - else - updatePatch(obj, dataIndex); - end - case 'rectangle' - updateRectangle(obj,dataIndex); - case 'surface' - updateSurfaceplot(obj,dataIndex); - - %-GROUP PLOT OBJECTS-% - case 'area' - updateArea(obj, dataIndex); - case 'areaseries' - updateAreaseries(obj, dataIndex); - case 'bar' - updateBar(obj, dataIndex); - case 'barseries' - updateBarseries(obj, dataIndex); - case 'baseline' - updateBaseline(obj, dataIndex); - case {'contourgroup','contour'} - updateContourgroup(obj,dataIndex); - case 'errorbar' - updateErrorbar(obj,dataIndex); - case 'errorbarseries' - updateErrorbarseries(obj,dataIndex); - case 'lineseries' - updateLineseries(obj, dataIndex); - case 'quiver' - updateQuiver(obj, dataIndex); - case 'quivergroup' - updateQuivergroup(obj, dataIndex); - case 'scatter' - updateScatter(obj, dataIndex); - case 'scattergroup' - updateScattergroup(obj, dataIndex); - case 'stair' - updateStair(obj, dataIndex); - case 'stairseries' - updateStairseries(obj, dataIndex); - case 'stem' - updateStem(obj, dataIndex); - case 'stemseries' - updateStemseries(obj, dataIndex); - case 'surfaceplot' - updateSurfaceplot(obj,dataIndex); - - %--Plotly supported MATLAB group plot objects--% - case {'hggroup','group'} - % check for boxplot - if isBoxplot(obj, dataIndex) - updateBoxplot(obj, dataIndex); - end - end - -catch exception - if obj.UserData.Verbose - fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',... - 'This trace might not render properly.\n\n']); - end -end - -%------------------------AXIS/DATA CLEAN UP-------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - -%-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) ';']); - -%-------------------------------------------------------------------------% - -% check for xaxis dates -if strcmpi(xaxis.type, 'date') - obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); -end - -% check for xaxis categories -if strcmpi(xaxis.type, 'category') && ... - ~strcmp(obj.data{dataIndex}.type,'box') - obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel'); -end - -% check for xaxis duration -if strcmpi(xaxis.type, 'duration') - obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); - xaxis.type = 'category'; -end - -% check for xaxis duration with input format -if strcmpi(xaxis.type, 'duration - specified format') - obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel'); - xaxis.type = 'category'; -end -%-------------------------------------------------------------------------% -% check for yaxis dates -if strcmpi(yaxis.type, 'date') - obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y); -end - -% check for yaxis categories -if strcmpi(yaxis.type, 'category') && ... - ~strcmp(obj.data{dataIndex}.type,'box') - obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); -end - -% check for yaxis duration -if strcmpi(yaxis.type, 'duration') - obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y); - yaxis.type = 'category'; -end - -% check for yaxis duration with input format -if strcmpi(yaxis.type, 'duration - specified format') - obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); - yaxis.type = 'category'; -end - -%-------------------------------------------------------------------------% - -end +%----UPDATE PLOT DATA/STYLE----% + +function obj = updateData(obj, dataIndex) + +%-update plot based on plot call class-% +try + switch lower(obj.State.Plot(dataIndex).Class) + + %--CORE PLOT OBJECTS--% + case 'image' + updateImage(obj, dataIndex); + case 'line' + updateLineseries(obj, dataIndex); + case 'histogram' + if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes') + updateHistogramPolar(obj, dataIndex); + else + updateHistogram(obj, dataIndex); + end + case 'histogram2' + updateHistogram2(obj, dataIndex); + case 'patch' + % check for histogram + if isHistogram(obj,dataIndex) + updateHistogram(obj,dataIndex); + else + updatePatch(obj, dataIndex); + end + case 'rectangle' + updateRectangle(obj,dataIndex); + case 'surface' + updateSurfaceplot(obj,dataIndex); + + %-GROUP PLOT OBJECTS-% + case 'area' + updateArea(obj, dataIndex); + case 'areaseries' + updateAreaseries(obj, dataIndex); + case 'bar' + updateBar(obj, dataIndex); + case 'barseries' + updateBarseries(obj, dataIndex); + case 'baseline' + updateBaseline(obj, dataIndex); + case {'contourgroup','contour'} + updateContourgroup(obj,dataIndex); + case 'errorbar' + updateErrorbar(obj,dataIndex); + case 'errorbarseries' + updateErrorbarseries(obj,dataIndex); + case 'lineseries' + updateLineseries(obj, dataIndex); + case 'quiver' + updateQuiver(obj, dataIndex); + case 'quivergroup' + updateQuivergroup(obj, dataIndex); + case 'scatter' + if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes') + updateScatterPolar(obj, dataIndex); + else + updateScatter(obj, dataIndex); + end + case 'scattergroup' + updateScattergroup(obj, dataIndex); + case 'stair' + updateStair(obj, dataIndex); + case 'stairseries' + updateStairseries(obj, dataIndex); + case 'stem' + updateStem(obj, dataIndex); + case 'stemseries' + updateStemseries(obj, dataIndex); + case 'surfaceplot' + updateSurfaceplot(obj,dataIndex); + case 'implicitfunctionline' + updateLineseries(obj, dataIndex); + + %--Plotly supported MATLAB group plot objects--% + case {'hggroup','group'} + % check for boxplot + if isBoxplot(obj, dataIndex) + updateBoxplot(obj, dataIndex); + end + end + +catch exception + if obj.UserData.Verbose + fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',... + 'This trace might not render properly.\n\n']); + end +end + +%------------------------AXIS/DATA CLEAN UP-------------------------------% + +try + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); + + %-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) ';']); + + %---------------------------------------------------------------------% + + % check for xaxis dates + if strcmpi(xaxis.type, 'date') + obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); + end + + % check for xaxis categories + if strcmpi(xaxis.type, 'category') && ... + ~strcmp(obj.data{dataIndex}.type,'box') + obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel'); + end + + % check for yaxis dates + if strcmpi(yaxis.type, 'date') + obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y); + end + + % check for yaxis categories + if strcmpi(yaxis.type, 'category') && ... + ~strcmp(obj.data{dataIndex}.type,'box') + obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); + end +catch + % TODO to the future +end + +%-------------------------------------------------------------------------% + +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m new file mode 100644 index 00000000..e25d6f18 --- /dev/null +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -0,0 +1,118 @@ +function obj = updateHistogramPolar(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); + +%-------------------------------------------------------------------------% + +%-barpolar type-% +obj.data{histIndex}.type = 'barpolar'; + +%-------------------------------------------------------------------------% + +%-barpolar data-% +binedges = rad2deg(hist_data.BinEdges); +obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); +obj.data{histIndex}.width = diff(binedges); +obj.data{histIndex}.r = double(hist_data.BinCounts); + +%-------------------------------------------------------------------------% + +%-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