Skip to content

Commit 8d83e0b

Browse files
Merge pull request #402 from plotly/adding_TernPlotPackage_functionalities_to_fig2plotly_properly
Adding ternplot package functionalities to fig2plotly properly
2 parents 5287af9 + 312efac commit 8d83e0b

File tree

7 files changed

+1267
-48
lines changed

7 files changed

+1267
-48
lines changed

plotly/plotlyfig.m

+16-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
obj.PlotOptions.Visible = 'on';
5454
obj.PlotOptions.TriangulatePatch = false;
5555
obj.PlotOptions.StripMargins = false;
56-
obj.PlotOptions.TreatAs = '_';
56+
obj.PlotOptions.TreatAs = {'_'};
5757
obj.PlotOptions.Image3D = false;
5858
obj.PlotOptions.ContourProjection = false;
5959
obj.PlotOptions.AxisEqual = false;
@@ -106,6 +106,7 @@
106106
obj.PlotlyDefaults.MinCaptionMargin = 80;
107107
obj.PlotlyDefaults.IsLight = false;
108108
obj.PlotlyDefaults.isGeoaxis = false;
109+
obj.PlotlyDefaults.isTernary = false;
109110

110111
%-State-%
111112
obj.State.Figure = [];
@@ -239,7 +240,11 @@
239240
obj.PlotOptions.TriangulatePatch = varargin{a+1};
240241
end
241242
if(strcmpi(varargin{a},'TreatAs'))
242-
obj.PlotOptions.TreatAs = varargin{a+1};
243+
if ~iscell(varargin{a+1})
244+
obj.PlotOptions.TreatAs = {varargin{a+1}};
245+
else
246+
obj.PlotOptions.TreatAs = varargin{a+1};
247+
end
243248
end
244249
if(strcmpi(varargin{a},'AxisEqual'))
245250
obj.PlotOptions.AxisEqual = varargin{a+1};
@@ -766,7 +771,9 @@ function validate(obj)
766771
elseif obj.PlotlyDefaults.isGeoaxis
767772
% TODO
768773
else
769-
updateAnnotation(obj,n);
774+
if ~obj.PlotlyDefaults.isTernary
775+
updateAnnotation(obj,n);
776+
end
770777
end
771778
catch
772779
% TODO to the future
@@ -787,7 +794,11 @@ function validate(obj)
787794

788795
% update colorbars
789796
for n = 1:obj.State.Figure.NumColorbars
790-
updateColorbar(obj,n);
797+
if ~obj.PlotlyDefaults.isTernary
798+
updateColorbar(obj,n);
799+
else
800+
updateTernaryColorbar(obj,n);
801+
end
791802
end
792803

793804
end
@@ -1086,6 +1097,7 @@ function delete(obj)
10861097
|| strcmpi(fieldname,'legend') || strcmpi(fieldname,'histogram')...
10871098
|| strcmpi(fieldname,'scatter') || strcmpi(fieldname,'line')...
10881099
|| strcmpi(fieldname,'scattergeo') || strcmpi(fieldname,'scattermapbox')...
1100+
|| strcmpi(fieldname,'scatterternary')...
10891101
)
10901102
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
10911103
end

plotly/plotlyfig_aux/core/updateData.m

+48-43
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,44 @@
55
try
66

77
%-update plot based on TreatAs PlotOpts-%
8-
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, 'comet') || strcmpi(obj.PlotOptions.TreatAs, 'comet3')
33-
updateComet(obj, dataIndex);
34-
elseif strcmpi(obj.PlotOptions.TreatAs, 'fmesh')
35-
updateFmesh(obj, dataIndex);
36-
elseif strcmpi(obj.PlotOptions.TreatAs, 'mesh')
37-
updateMesh(obj, dataIndex);
38-
elseif strcmpi(obj.PlotOptions.TreatAs, 'surfc')
39-
updateSurfc(obj, dataIndex);
40-
elseif strcmpi(obj.PlotOptions.TreatAs, 'meshc')
41-
updateSurfc(obj, dataIndex);
42-
elseif strcmpi(obj.PlotOptions.TreatAs, 'surfl')
43-
updateSurfl(obj, dataIndex);
8+
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);
4441

45-
% this one will be revomed
46-
elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
47-
updateStreamtube(obj, dataIndex);
48-
end
42+
% this one will be revomed
43+
% elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
44+
% updateStreamtube(obj, dataIndex);
45+
% end
4946

5047
%-update plot based on plot call class-%
5148

@@ -75,6 +72,8 @@
7572
case 'line'
7673
if obj.PlotlyDefaults.isGeoaxis
7774
updateGeoPlot(obj, dataIndex);
75+
elseif ismember('ternplot', lower(obj.PlotOptions.TreatAs))
76+
updateTernaryPlot(obj, dataIndex);
7877
else
7978
updateLineseries(obj, dataIndex);
8079
end
@@ -88,6 +87,10 @@
8887
% check for histogram
8988
if isHistogram(obj,dataIndex)
9089
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);
9194
else
9295
updatePatch(obj, dataIndex);
9396
end
@@ -114,10 +117,12 @@
114117
case 'baseline'
115118
updateBaseline(obj, dataIndex);
116119
case {'contourgroup','contour'}
117-
if ~obj.PlotOptions.ContourProjection
118-
updateContourgroup(obj,dataIndex);
119-
else
120+
if obj.PlotOptions.ContourProjection
120121
updateContourProjection(obj,dataIndex);
122+
elseif ismember('terncontour', lower(obj.PlotOptions.TreatAs))
123+
updateTernaryContour(obj, dataIndex);
124+
else
125+
updateContourgroup(obj,dataIndex);
121126
end
122127
case 'functioncontour'
123128
updateFunctionContour(obj,dataIndex);

0 commit comments

Comments
 (0)