Skip to content

Commit 6b00c74

Browse files
Merge pull request #345 from plotly/issue204_fixed_heatmap
Issue204 fixed heatmap
2 parents 3b4fbec + b7dd590 commit 6b00c74

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

plotly/plotlyfig.m

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ function validate(obj)
450450

451451
% handle title (for feed)
452452
if obj.PlotOptions.CleanFeedTitle
453-
cleanFeedTitle(obj);
453+
try
454+
cleanFeedTitle(obj);
455+
catch
456+
% TODO to the future
457+
end
454458
end
455459

456460
%get args
@@ -642,7 +646,7 @@ function validate(obj)
642646
updateAxis(obj,n);
643647
catch
644648
% TODO to the future
645-
disp('catch at line 643 in plotlyfog.m file')
649+
% disp('catch at line 647 in plotlyfig.m file')
646650
end
647651
end
648652

@@ -657,18 +661,22 @@ function validate(obj)
657661
end
658662
catch
659663
% TODO to the future
660-
disp('catch at line 660 in plotlyfog.m file')
664+
% disp('catch at line 664 in plotlyfig.m file')
661665
end
662666

663667
end
664668

665669
% update annotations
666670
for n = 1:obj.State.Figure.NumTexts
667671
try
668-
updateAnnotation(obj,n);
672+
if ~strcmpi(obj.State.Plot(dataIndex).Class, 'heatmap')
673+
updateAnnotation(obj,n);
674+
else
675+
obj.PlotOptions.CleanFeedTitle = false;
676+
end
669677
catch
670678
% TODO to the future
671-
disp('catch at line 671 in plotlyfog.m file')
679+
% disp('catch at line 679 in plotlyfig.m file')
672680
end
673681
end
674682

@@ -973,6 +981,7 @@ function delete(obj)
973981
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
974982
|| strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
975983
|| strcmpi(fieldname,'scene') || strcmpi(fieldname,'layout') ...
984+
|| strcmpi(fieldname,'heatmap') ...
976985
)
977986
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
978987
end

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
switch lower(obj.State.Plot(dataIndex).Class)
2323

2424
%--CORE PLOT OBJECTS--%
25+
case 'heatmap'
26+
updateHeatmap(obj, dataIndex);
2527
case 'image'
2628
updateImage(obj, dataIndex);
2729
case 'line'
@@ -152,7 +154,7 @@
152154
end
153155
catch
154156
% TODO to the future
155-
disp('catch at line 155 in updateData.m file')
157+
% disp('catch at line 157 in updateData.m file')
156158
end
157159

158160
%-------------------------------------------------------------------------%
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
function obj = updateHeatmap(obj,heatIndex)
2+
3+
%-------------------------------------------------------------------------%
4+
5+
%-HEATMAP DATA STRUCTURE- %
6+
heat_data = get(obj.State.Plot(heatIndex).Handle);
7+
%-------------------------------------------------------------------------%
8+
9+
%-heatmap type-%
10+
obj.data{heatIndex}.type = 'heatmap';
11+
12+
%-------------------------------------------------------------------------%
13+
14+
%-format data-%
15+
obj.data{heatIndex}.x = heat_data.XData;
16+
obj.data{heatIndex}.y = heat_data.YData;
17+
obj.data{heatIndex}.z = heat_data.ColorData(end:-1:1, :);
18+
19+
%-------------------------------------------------------------------------%
20+
21+
%-heatmap colorscale-%
22+
cmap = heat_data.Colormap;
23+
len = length(cmap)-1;
24+
25+
for c = 1: length(cmap)
26+
col = 255 * cmap(c, :);
27+
obj.data{heatIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] };
28+
end
29+
30+
%-------------------------------------------------------------------------%
31+
32+
%-setting plot-%
33+
obj.data{heatIndex}.hoverinfo = 'text';
34+
obj.data{heatIndex}.text = heat_data.ColorData(end:-1:1, :);
35+
obj.data{heatIndex}.hoverlabel.bgcolor = 'white';
36+
37+
%-------------------------------------------------------------------------%
38+
39+
%-show colorbar-%
40+
obj.data{heatIndex}.showscale = false;
41+
if strcmpi(heat_data.ColorbarVisible, 'on')
42+
obj.data{heatIndex}.showscale = true;
43+
end
44+
45+
%-------------------------------------------------------------------------%
46+
47+
%-hist visible-%
48+
obj.data{heatIndex}.visible = strcmp(heat_data.Visible,'on');
49+
50+
%-------------------------------------------------------------------------%
51+
52+
end

plotly/plotlyfig_aux/helpers/parseString.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
end
248248
end
249249
end
250+
else
251+
formatStr = 'untitled';
250252
end
251253

252254

0 commit comments

Comments
 (0)