Skip to content

Commit ae74708

Browse files
authored
Merge branch 'master' into issue172
2 parents 015c124 + edcf9b0 commit ae74708

File tree

10 files changed

+338
-53
lines changed

10 files changed

+338
-53
lines changed

plotly/plotly_offline_aux/plotlyoffline.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@
6060
'\n });'], id, clean_jdata, clean_jlayout, ...
6161
id, link_text);
6262

63-
plotly_script = sprintf(['\n<div class="%s loading" style=', ...
64-
'color: rgb(50,50,50);">Drawing...</div>' ...
65-
'\n<div id="%s" style="height: %s;',...
63+
plotly_script = sprintf(['\n<div id="%s" style="height: %s;',...
6664
'width: %s;" class="plotly-graph-div">' ...
6765
'</div> \n<script type="text/javascript">' ...
68-
'%s \n</script>'], id, id, height, width, ...
66+
'%s \n</script>'], id, height, width, ...
6967
script);
7068

7169
% template entire script

plotly/plotlyfig.m

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
obj.PlotOptions.OpenURL = true;
5959
obj.PlotOptions.Strip = false;
6060
obj.PlotOptions.Visible = 'on';
61-
obj.PlotOptions.TriangulatePatch = false;
61+
obj.PlotOptions.TriangulatePatch = false;
62+
obj.PlotOptions.StripMargins = false;
6263

6364
% offline options
6465
obj.PlotOptions.Offline = true;
@@ -192,6 +193,9 @@
192193
if(strcmpi(varargin{a},'data'))
193194
obj.data = varargin{a+1};
194195
end
196+
if(strcmpi(varargin{a},'StripMargins'))
197+
obj.PlotOptions.StripMargins = varargin{a+1};
198+
end
195199
end
196200
end
197201

@@ -237,8 +241,6 @@
237241

238242
% plotly reference
239243
plotlyref = load('plotly_reference.mat');
240-
% rmfield(plotlyref.pr, 'xbins');
241-
% plotlyref.pr.xbins.size
242244

243245
% update the PlotlyRef property
244246
obj.PlotlyReference = plotlyref.pr;
@@ -425,6 +427,14 @@ function validate(obj)
425427
obj.strip;
426428
end
427429

430+
% strip margins
431+
if obj.PlotOptions.StripMargins
432+
obj.layout.margin.l = 0;
433+
obj.layout.margin.r = 0;
434+
obj.layout.margin.b = 0;
435+
obj.layout.margin.t = 0;
436+
end
437+
428438
% validate keys
429439
validate(obj);
430440

@@ -480,7 +490,32 @@ function validate(obj)
480490
obj.State.Figure.NumTexts = 0;
481491

482492
% find axes of figure
483-
ax = findobj(obj.State.Figure.Handle,'Type','axes','-and',{'Tag','','-or','Tag','PlotMatrixBigAx','-or','Tag','PlotMatrixScatterAx'});
493+
ax = findobj(obj.State.Figure.Handle,'Type','axes','-and',{'Tag','','-or','Tag','PlotMatrixBigAx','-or','Tag','PlotMatrixScatterAx', '-or','Tag','PlotMatrixHistAx'});
494+
if isempty(ax)
495+
ax = gca;
496+
end
497+
498+
%---------- checking the overlaping of the graphs ----------%
499+
temp_ax = ax; deleted_idx = 0;
500+
for i = 1:length(ax)
501+
for j = i:length(ax)
502+
if ((mean(eq(ax(i).Position, ax(j).Position)) == 1) && (i~=j))
503+
temp_plots = findobj(temp_ax(i),'-not','Type','Text','-not','Type','axes','-depth',1);
504+
if ~ischar(temp_plots.FaceAlpha)
505+
update_opac(i) = true;
506+
else
507+
update_opac(i) = false;
508+
end
509+
temp_ax(i).YTick = temp_ax(j- deleted_idx).YTick;
510+
temp_ax(i).XTick = temp_ax(j- deleted_idx).XTick;
511+
temp_ax(j - deleted_idx) = [];
512+
deleted_idx = deleted_idx + 1;
513+
end
514+
end
515+
end
516+
ax = temp_ax;
517+
%---------- checking the overlaping of the graphs ----------%
518+
484519
obj.State.Figure.NumAxes = length(ax);
485520

486521
% update number of annotations (one title per axis)
@@ -586,17 +621,29 @@ function validate(obj)
586621

587622
% update axes
588623
for n = 1:obj.State.Figure.NumAxes
589-
updateAxis(obj,n);
624+
try
625+
updateAxis(obj,n);
626+
end
590627
end
591628

592629
% update plots
593630
for n = 1:obj.State.Figure.NumPlots
594631
updateData(obj,n);
632+
633+
try
634+
if (strcmp(obj.data{n}.type, 'bar') && update_opac(length(ax)-n))
635+
obj.data{1, n}.opacity = 0.9;
636+
obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)';
637+
end
638+
end
639+
595640
end
596641

597642
% update annotations
598643
for n = 1:obj.State.Figure.NumTexts
599-
updateAnnotation(obj,n);
644+
try
645+
updateAnnotation(obj,n);
646+
end
600647
end
601648

602649
% update legends
@@ -838,7 +885,7 @@ function delete(obj)
838885
fnmod = fn;
839886

840887
try
841-
for d = 1:length(fn);
888+
for d = 1:length(fn)
842889

843890
% clean up axis keys
844891
if any(strfind(fn{d},'xaxis')) || any(strfind(fn{d},'yaxis'))

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
case 'quivergroup'
5252
updateQuivergroup(obj, dataIndex);
5353
case 'scatter'
54-
updateScatter(obj, dataIndex);
54+
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
55+
updateScatterPolar(obj, dataIndex);
56+
else
57+
updateScatter(obj, dataIndex);
58+
end
5559
case 'scattergroup'
5660
updateScattergroup(obj, dataIndex);
5761
case 'stair'
@@ -64,7 +68,7 @@
6468
updateStemseries(obj, dataIndex);
6569
case 'surfaceplot'
6670
updateSurfaceplot(obj,dataIndex);
67-
case 'functionline'
71+
case {'functionline', 'implicitfunctionline'}
6872
updateLineseries(obj, dataIndex);
6973
%--Plotly supported MATLAB group plot objects--%
7074
case {'hggroup','group'}
@@ -83,38 +87,40 @@
8387

8488
%------------------------AXIS/DATA CLEAN UP-------------------------------%
8589

86-
%-AXIS INDEX-%
87-
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);
90+
try
91+
%-AXIS INDEX-%
92+
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);
8893

89-
%-CHECK FOR MULTIPLE AXES-%
90-
[xsource, ysource] = findSourceAxis(obj,axIndex);
94+
%-CHECK FOR MULTIPLE AXES-%
95+
[xsource, ysource] = findSourceAxis(obj,axIndex);
9196

92-
%-AXIS DATA-%
93-
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
94-
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
97+
%-AXIS DATA-%
98+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
99+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
95100

96-
%-------------------------------------------------------------------------%
101+
%---------------------------------------------------------------------%
97102

98-
% check for xaxis dates
99-
if strcmpi(xaxis.type, 'date')
100-
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
101-
end
103+
% check for xaxis dates
104+
if strcmpi(xaxis.type, 'date')
105+
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
106+
end
102107

103-
% check for xaxis categories
104-
if strcmpi(xaxis.type, 'category') && ...
105-
~strcmp(obj.data{dataIndex}.type,'box')
106-
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
107-
end
108+
% check for xaxis categories
109+
if strcmpi(xaxis.type, 'category') && ...
110+
~strcmp(obj.data{dataIndex}.type,'box')
111+
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
112+
end
108113

109-
% check for yaxis dates
110-
if strcmpi(yaxis.type, 'date')
111-
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
112-
end
114+
% check for yaxis dates
115+
if strcmpi(yaxis.type, 'date')
116+
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
117+
end
113118

114-
% check for yaxis categories
115-
if strcmpi(yaxis.type, 'category') && ...
116-
~strcmp(obj.data{dataIndex}.type,'box')
117-
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
119+
% check for yaxis categories
120+
if strcmpi(yaxis.type, 'category') && ...
121+
~strcmp(obj.data{dataIndex}.type,'box')
122+
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
123+
end
118124
end
119125

120126
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/handlegraphics/updateLineseries.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,18 @@ function updateLineseries(obj,plotIndex)
6565

6666
%-------------------------------------------------------------------------%
6767

68-
%-if compass or not-%
69-
iscompass = false;
68+
%-if polar plot or not-%
69+
ispolar = false;
7070
x = plot_data.XData;
7171
y = plot_data.YData;
7272

7373
if length(x)==5 && length(y)==5 && x(2)==x(4) && y(2)==y(4)
74-
iscompass = true;
74+
ispolar = true;
75+
end
76+
77+
%-if polar ezplot or not-%
78+
if abs(x(1)-x(end))<1e-5 && abs(y(1)-y(end))<1e-5
79+
ispolar = true;
7580
end
7681

7782
%-------------------------------------------------------------------------%
@@ -89,7 +94,7 @@ function updateLineseries(obj,plotIndex)
8994
%-scatter type-%
9095
obj.data{plotIndex}.type = 'scatter';
9196

92-
if iscompass
97+
if ispolar
9398
obj.data{plotIndex}.type = 'scatterpolar';
9499
end
95100

@@ -102,7 +107,7 @@ function updateLineseries(obj,plotIndex)
102107

103108
%-scatter x-%
104109

105-
if iscompass
110+
if ispolar
106111
r = sqrt(x.^2 + y.^2);
107112
obj.data{plotIndex}.r = r;
108113
else
@@ -112,7 +117,7 @@ function updateLineseries(obj,plotIndex)
112117
%-------------------------------------------------------------------------%
113118

114119
%-scatter y-%
115-
if iscompass
120+
if ispolar
116121
theta = atan2(x,y);
117122
obj.data{plotIndex}.theta = -(rad2deg(theta) - 90);
118123
else

plotly/plotlyfig_aux/handlegraphics/updateQuiver.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
%-quiver line color-%
5151
col = 255*quiver_data.Color;
52-
obj.data{quiverIndex}.line.color = ['rgb(' col(1) ',' col(2) ',' col(3) ')'];
52+
obj.data{quiverIndex}.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
5353

5454
%------------------------------------------------------------------------%
5555

0 commit comments

Comments
 (0)