Skip to content

Commit 9597bfd

Browse files
adding TernPlot-Package's functionalities to fig2plotly properly
1 parent bffcbaf commit 9597bfd

File tree

7 files changed

+1267
-46
lines changed

7 files changed

+1267
-46
lines changed

plotly/plotlyfig.m

+16-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
obj.PlotOptions.Visible = 'on';
5252
obj.PlotOptions.TriangulatePatch = false;
5353
obj.PlotOptions.StripMargins = false;
54-
obj.PlotOptions.TreatAs = '_';
54+
obj.PlotOptions.TreatAs = {'_'};
5555
obj.PlotOptions.Image3D = false;
5656
obj.PlotOptions.ContourProjection = false;
5757
obj.PlotOptions.AxisEqual = false;
@@ -102,6 +102,7 @@
102102
obj.PlotlyDefaults.MinCaptionMargin = 80;
103103
obj.PlotlyDefaults.IsLight = false;
104104
obj.PlotlyDefaults.isGeoaxis = false;
105+
obj.PlotlyDefaults.isTernary = false;
105106

106107
%-State-%
107108
obj.State.Figure = [];
@@ -235,7 +236,11 @@
235236
obj.PlotOptions.TriangulatePatch = varargin{a+1};
236237
end
237238
if(strcmpi(varargin{a},'TreatAs'))
238-
obj.PlotOptions.TreatAs = varargin{a+1};
239+
if ~iscell(varargin{a+1})
240+
obj.PlotOptions.TreatAs = {varargin{a+1}};
241+
else
242+
obj.PlotOptions.TreatAs = varargin{a+1};
243+
end
239244
end
240245
if(strcmpi(varargin{a},'AxisEqual'))
241246
obj.PlotOptions.AxisEqual = varargin{a+1};
@@ -752,7 +757,9 @@ function validate(obj)
752757
elseif obj.PlotlyDefaults.isGeoaxis
753758
% TODO
754759
else
755-
updateAnnotation(obj,n);
760+
if ~obj.PlotlyDefaults.isTernary
761+
updateAnnotation(obj,n);
762+
end
756763
end
757764
catch
758765
% TODO to the future
@@ -773,7 +780,11 @@ function validate(obj)
773780

774781
% update colorbars
775782
for n = 1:obj.State.Figure.NumColorbars
776-
updateColorbar(obj,n);
783+
if ~obj.PlotlyDefaults.isTernary
784+
updateColorbar(obj,n);
785+
else
786+
updateTernaryColorbar(obj,n);
787+
end
777788
end
778789

779790
end
@@ -1072,6 +1083,7 @@ function delete(obj)
10721083
|| strcmpi(fieldname,'legend') || strcmpi(fieldname,'histogram')...
10731084
|| strcmpi(fieldname,'scatter') || strcmpi(fieldname,'line')...
10741085
|| strcmpi(fieldname,'scattergeo') || strcmpi(fieldname,'scattermapbox')...
1086+
|| strcmpi(fieldname,'scatterternary')...
10751087
)
10761088
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
10771089
end

plotly/plotlyfig_aux/core/updateData.m

+48-41
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,43 @@
66

77
%-update plot based on TreatAs PlotOpts-%
88

9-
if ~strcmpi(obj.PlotOptions.TreatAs, '_')
10-
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
11-
updatePie3(obj, dataIndex);
12-
elseif strcmpi(obj.PlotOptions.TreatAs, 'pcolor')
13-
updatePColor(obj, dataIndex);
14-
elseif strcmpi(obj.PlotOptions.TreatAs, 'polarplot')
15-
updatePolarplot(obj, dataIndex);
16-
elseif strcmpi(obj.PlotOptions.TreatAs, 'contour3')
17-
updateContour3(obj, dataIndex);
18-
elseif strcmpi(obj.PlotOptions.TreatAs, 'compass')
19-
updateLineseries(obj, dataIndex);
20-
elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar')
21-
updateLineseries(obj, dataIndex);
22-
elseif strcmpi(obj.PlotOptions.TreatAs, 'polarhistogram')
23-
updateHistogramPolar(obj, dataIndex);
24-
elseif strcmpi(obj.PlotOptions.TreatAs, 'coneplot')
25-
updateConeplot(obj, dataIndex);
26-
elseif strcmpi(obj.PlotOptions.TreatAs, 'bar3')
27-
updateBar3(obj, dataIndex);
28-
elseif strcmpi(obj.PlotOptions.TreatAs, 'bar3h')
29-
updateBar3h(obj, dataIndex);
30-
elseif strcmpi(obj.PlotOptions.TreatAs, 'surf')
31-
updateSurf(obj, dataIndex);
32-
elseif strcmpi(obj.PlotOptions.TreatAs, 'fmesh')
33-
updateFmesh(obj, dataIndex);
34-
elseif strcmpi(obj.PlotOptions.TreatAs, 'mesh')
35-
updateMesh(obj, dataIndex);
36-
elseif strcmpi(obj.PlotOptions.TreatAs, 'surfc')
37-
updateSurfc(obj, dataIndex);
38-
elseif strcmpi(obj.PlotOptions.TreatAs, 'meshc')
39-
updateSurfc(obj, dataIndex);
40-
elseif strcmpi(obj.PlotOptions.TreatAs, 'surfl')
41-
updateSurfl(obj, dataIndex);
42-
43-
% this one will be revomed
44-
elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
45-
updateStreamtube(obj, dataIndex);
46-
end
9+
if ismember('pie3', lower(obj.PlotOptions.TreatAs))
10+
updatePie3(obj, dataIndex);
11+
elseif ismember('pcolor', lower(obj.PlotOptions.TreatAs))
12+
updatePColor(obj, dataIndex);
13+
elseif ismember('polarplot', lower(obj.PlotOptions.TreatAs))
14+
updatePolarplot(obj, dataIndex);
15+
elseif ismember('contour3', lower(obj.PlotOptions.TreatAs))
16+
updateContour3(obj, dataIndex);
17+
elseif ismember('compass', lower(obj.PlotOptions.TreatAs))
18+
updateLineseries(obj, dataIndex);
19+
elseif ismember('ezpolar', lower(obj.PlotOptions.TreatAs))
20+
updateLineseries(obj, dataIndex);
21+
elseif ismember('polarhistogram', lower(obj.PlotOptions.TreatAs))
22+
updateHistogramPolar(obj, dataIndex);
23+
elseif ismember('coneplot', lower(obj.PlotOptions.TreatAs))
24+
updateConeplot(obj, dataIndex);
25+
elseif ismember('bar3', lower(obj.PlotOptions.TreatAs))
26+
updateBar3(obj, dataIndex);
27+
elseif ismember('bar3h', lower(obj.PlotOptions.TreatAs))
28+
updateBar3h(obj, dataIndex);
29+
elseif ismember('surf', lower(obj.PlotOptions.TreatAs))
30+
updateSurf(obj, dataIndex);
31+
elseif ismember('fmesh', lower(obj.PlotOptions.TreatAs))
32+
updateFmesh(obj, dataIndex);
33+
elseif ismember('mesh', lower(obj.PlotOptions.TreatAs))
34+
updateMesh(obj, dataIndex);
35+
elseif ismember('surfc', lower(obj.PlotOptions.TreatAs))
36+
updateSurfc(obj, dataIndex);
37+
elseif ismember('meshc', lower(obj.PlotOptions.TreatAs))
38+
updateSurfc(obj, dataIndex);
39+
elseif ismember('surfl', lower(obj.PlotOptions.TreatAs))
40+
updateSurfl(obj, dataIndex);
41+
42+
% this one will be revomed
43+
% elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
44+
% updateStreamtube(obj, dataIndex);
45+
% end
4746

4847
%-update plot based on plot call class-%
4948

@@ -73,6 +72,8 @@
7372
case 'line'
7473
if obj.PlotlyDefaults.isGeoaxis
7574
updateGeoPlot(obj, dataIndex);
75+
elseif ismember('ternplot', lower(obj.PlotOptions.TreatAs))
76+
updateTernaryPlot(obj, dataIndex);
7677
else
7778
updateLineseries(obj, dataIndex);
7879
end
@@ -86,6 +87,10 @@
8687
% check for histogram
8788
if isHistogram(obj,dataIndex)
8889
updateHistogram(obj,dataIndex);
90+
elseif ismember('ternplotpro', lower(obj.PlotOptions.TreatAs))
91+
updateTernaryPlotPro(obj, dataIndex);
92+
elseif ismember('ternpcolor', lower(obj.PlotOptions.TreatAs))
93+
updateTernaryPlotPro(obj, dataIndex);
8994
else
9095
updatePatch(obj, dataIndex);
9196
end
@@ -110,10 +115,12 @@
110115
case 'baseline'
111116
updateBaseline(obj, dataIndex);
112117
case {'contourgroup','contour'}
113-
if ~obj.PlotOptions.ContourProjection
114-
updateContourgroup(obj,dataIndex);
115-
else
118+
if obj.PlotOptions.ContourProjection
116119
updateContourProjection(obj,dataIndex);
120+
elseif ismember('terncontour', lower(obj.PlotOptions.TreatAs))
121+
updateTernaryContour(obj, dataIndex);
122+
else
123+
updateContourgroup(obj,dataIndex);
117124
end
118125
case 'functioncontour'
119126
updateFunctionContour(obj,dataIndex);

0 commit comments

Comments
 (0)