Skip to content

Commit 4f90ad5

Browse files
Fix color issues
1 parent 52f5d80 commit 4f90ad5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+374
-450
lines changed

plotly/plotlyfig_aux/core/updateAnnotation.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@
141141

142142

143143
%-font color-%
144-
col = 255*text_data.Color;
144+
col = round(255*text_data.Color);
145145
obj.layout.annotations{anIndex}.font.color = ...
146-
sprintf("rgba(%d,%d,%d)", col);
146+
sprintf("rgb(%d,%d,%d)", col);
147147

148148
%---------------------------------------------------------------------%
149149

@@ -181,7 +181,7 @@
181181

182182
%-border color-%
183183
if ~ischar(text_data.EdgeColor)
184-
col = 255*text_data.EdgeColora;
184+
col = round(255*text_data.EdgeColora);
185185
obj.layout.annotations{anIndex}.bordercolor = ...
186186
sprintf("rgb(%d,%d,%d)", col);
187187
else

plotly/plotlyfig_aux/core/updateColorbar.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
outlineColor = [0 0 0];
5353
else
5454
if colorbarData.Position(4) > colorbarData.Position(3)
55-
outlineColor = 255*colorbarData.YColor;
55+
outlineColor = round(255*colorbarData.YColor);
5656
else
57-
outlineColor = 255*colorbarData.XColor;
57+
outlineColor = round(255*colorbarData.XColor);
5858
end
5959
end
6060

61-
outlineColor = sprintf('rgb(%f,%f,%f)', outlineColor);
61+
outlineColor = sprintf("rgb(%d,%d,%d)", outlineColor);
6262
lineWidth = colorbarData.LineWidth ...
6363
* obj.PlotlyDefaults.AxisLineIncreaseFactor;
6464
tickLength = min(obj.PlotlyDefaults.MaxTickLength, ...
@@ -147,8 +147,8 @@
147147
end
148148

149149
titleFontSize = 1.20 * colorbarTitleData.FontSize;
150-
titleFontColor = ...
151-
sprintf('rgb(%f,%f,%f)', 255*colorbarTitleData.Color);
150+
titleFontColor = sprintf("rgb(%d,%d,%d)", ...
151+
round(255*colorbarTitleData.Color));
152152
titleFontFamily = matlab2plotlyfont(colorbarTitleData.FontName);
153153

154154
elseif ~isempty(colorbarXLabelData.String)
@@ -157,8 +157,8 @@
157157

158158
titleSide = 'right';
159159
titleFontSize = 1.20 * colorbarXLabelData.FontSize;
160-
titleFontColor = ...
161-
sprintf('rgb(%f,%f,%f)', 255*colorbarXLabelData.Color);
160+
titleFontColor = sprintf("rgb(%d,%d,%d)", ...
161+
round(255*colorbarXLabelData.Color));
162162
titleFontFamily = matlab2plotlyfont(colorbarXLabelData.FontName);
163163

164164
elseif ~isempty(colorbarYLabelData.String)
@@ -167,8 +167,8 @@
167167

168168
titleSide = 'bottom';
169169
titleFontSize = 1.20 * colorbarYLabelData.FontSize;
170-
titleFontColor = ...
171-
sprintf('rgb(%f,%f,%f)', 255*colorbarYLabelData.Color);
170+
titleFontColor = sprintf("rgb(%d,%d,%d)", ...
171+
round(255*colorbarYLabelData.Color));
172172
titleFontFamily = matlab2plotlyfont(colorbarYLabelData.FontName);
173173

174174
else
@@ -244,12 +244,12 @@
244244
%-colorbar bg-color-%
245245
if ~isHG2
246246
if ~ischar(colorbarData.Color)
247-
bgColor = 255*colorbarData.Color;
247+
bgColor = round(255*colorbarData.Color);
248248
else
249-
bgColor = 255*figureData.Color;
249+
bgColor = round(255*figureData.Color);
250250
end
251251

252-
obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f', bgColor);
252+
obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", bgColor);
253253
end
254254

255255
%---------------------------------------------------------------------%

plotly/plotlyfig_aux/core/updateLegend.m

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,83 +23,32 @@
2323
% only displays last legend as global Plotly legend
2424
obj.layout.legend = struct();
2525

26-
%---------------------------------------------------------------------%
27-
28-
%-layout showlegend-%
2926
obj.layout.showlegend = strcmpi(legend_data.Visible,'on');
30-
31-
%---------------------------------------------------------------------%
32-
33-
%-legend x-%
3427
obj.layout.legend.x = legend_data.Position(1);
35-
36-
%---------------------------------------------------------------------%
37-
38-
%-legend xref-%
3928
obj.layout.legend.xref = 'paper';
40-
41-
%---------------------------------------------------------------------%
42-
43-
%-legend xanchor-%
4429
obj.layout.legend.xanchor = 'left';
45-
46-
%---------------------------------------------------------------------%
47-
48-
%-legend y-%
4930
obj.layout.legend.y = legend_data.Position(2);
50-
51-
%---------------------------------------------------------------------%
52-
53-
%-legend yref-%
5431
obj.layout.legend.yref = 'paper';
55-
56-
%---------------------------------------------------------------------%
57-
58-
%-legend yanchor-%
5932
obj.layout.legend.yanchor = 'bottom';
6033

61-
%---------------------------------------------------------------------%
6234

63-
if (strcmp(legend_data.Box,'on') && strcmp(legend_data.Visible, 'on'))
64-
%-legend traceorder-%
35+
if (strcmp(legend_data.Box, 'on') && strcmp(legend_data.Visible, 'on'))
6536
obj.layout.legend.traceorder = 'normal';
66-
67-
%-----------------------------------------------------------------%
68-
69-
%-legend borderwidth-%
7037
obj.layout.legend.borderwidth = legend_data.LineWidth;
7138

72-
%-----------------------------------------------------------------%
39+
col = round(255*legend_data.EdgeColor);
40+
obj.layout.legend.bordercolor = sprintf("rgb(%d,%d,%d)", col);
7341

74-
%-legend bordercolor-%
75-
col = 255*legend_data.EdgeColor;
76-
obj.layout.legend.bordercolor = sprintf("rgb(%f,%f,%f)", col);
42+
col = round(255*legend_data.Color);
43+
obj.layout.legend.bgcolor = sprintf("rgb(%d,%d,%d)", col);
7744

78-
%-----------------------------------------------------------------%
79-
80-
%-legend bgcolor-%
81-
col = 255*legend_data.Color;
82-
obj.layout.legend.bgcolor = sprintf("rgb(%f,%f,%f)", col);
83-
84-
%-----------------------------------------------------------------%
85-
86-
%-legend font size-%
8745
obj.layout.legend.font.size = legend_data.FontSize;
88-
89-
%-----------------------------------------------------------------%
90-
91-
%-legend font family-%
9246
obj.layout.legend.font.family = ...
9347
matlab2plotlyfont(legend_data.FontName);
94-
95-
%-----------------------------------------------------------------%
96-
97-
%-legend font colour-%
98-
col = 255*legend_data.TextColor;
99-
obj.layout.legend.font.color = sprintf("rgb(%f,%f,%f)", col);
100-
end
10148

102-
%---------------------------------------------------------------------%
49+
col = round(255*legend_data.TextColor);
50+
obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col);
51+
end
10352

10453
%-REVERT UNITS-%
10554
set(obj.State.Legend(legIndex).Handle,'Units',legendunits);

plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
%-legend (x,y) coordenates-%
6666
obj.layout.legend.x = 1.005 * max(allDomain(:,1));
67-
obj.layout.legend.y = 1.001 * max(allDomain(:,2));;
67+
obj.layout.legend.y = 1.001 * max(allDomain(:,2));
6868

6969
%-legend (x,y) refs-%
7070
obj.layout.legend.xref = 'paper';
@@ -74,50 +74,25 @@
7474
obj.layout.legend.xanchor = 'left';
7575
obj.layout.legend.yanchor = 'top';
7676

77-
%---------------------------------------------------------------------%
78-
79-
if (strcmp(legendData.Box,'on') && strcmp(legendData.Visible, 'on'))
80-
%-legend traceorder-%
77+
if (strcmp(legendData.Box, 'on') && strcmp(legendData.Visible, 'on'))
8178
obj.layout.legend.traceorder = 'normal';
82-
83-
%-----------------------------------------------------------------%
84-
85-
%-legend borderwidth-%
8679
obj.layout.legend.borderwidth = legendData.LineWidth;
87-
88-
%-----------------------------------------------------------------%
89-
90-
%-legend bordercolor-%
91-
col = 255*legendData.EdgeColor;
92-
obj.layout.legend.bordercolor = sprintf('rgb(%f,%f,%f)', col);
93-
94-
%-----------------------------------------------------------------%
95-
96-
%-legend bgcolor-%
97-
col = 255*legendData.Color;
98-
obj.layout.legend.bgcolor = sprintf('rgb(%f,%f,%f)', col);
99-
100-
%-----------------------------------------------------------------%
101-
102-
%-legend font size-%
80+
81+
col = round(255*legendData.EdgeColor);
82+
obj.layout.legend.bordercolor = sprintf("rgb(%d,%d,%d)", col);
83+
84+
col = round(255*legendData.Color);
85+
obj.layout.legend.bgcolor = sprintf("rgb(%d,%d,%d)", col);
86+
10387
obj.layout.legend.font.size = legendData.FontSize;
104-
105-
%-----------------------------------------------------------------%
106-
107-
%-legend font family-%
10888
obj.layout.legend.font.family = ...
10989
matlab2plotlyfont(legendData.FontName);
110-
111-
%-----------------------------------------------------------------%
112-
113-
%-legend font colour-%
114-
col = 255*legendData.TextColor;
115-
obj.layout.legend.font.color = sprintf('rgb(%f,%f,%f)', col);
90+
91+
col = round(255*legendData.TextColor);
92+
obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col);
11693

11794
end
11895

119-
%---------------------------------------------------------------------%
120-
12196
%-REVERT UNITS-%
12297
set(obj.State.Legend(legIndex).Handle,'Units', legendUnits);
12398
set(obj.State.Legend(legIndex).Handle,'FontUnits', fontUnits);

plotly/plotlyfig_aux/core/updateTernaryColorbar.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,24 @@
117117

118118
colorbar.titlefont.family = ...
119119
matlab2plotlyfont(colorbarTitleData.FontName);
120-
col = 255*colorbarTitleData.Color;
121-
colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col);
120+
col = round(255*colorbarTitleData.Color);
121+
colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col);
122122
colorbar.titlefont.size = 1.20 * colorbarTitleData.FontSize;
123123

124124
elseif ~isempty(colorbarXLabelData.String)
125125
colorbar.titleside = 'right';
126126
colorbar.titlefont.family = ...
127127
matlab2plotlyfont(colorbarXLabelData.FontName);
128-
col = 255*colorbarXLabelData.Color;
129-
colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col);
128+
col = round(255*colorbarXLabelData.Color);
129+
colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col);
130130
colorbar.titlefont.size = 1.20 * colorbarXLabelData.FontSize;
131131

132132
elseif ~isempty(colorbarYLabelData.String)
133133
colorbar.titleside = 'bottom';
134134
colorbar.titlefont.family = ...
135135
matlab2plotlyfont(colorbarYLabelData.FontName);
136-
col = 255*colorbarYLabelData.Color;
137-
colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col);
136+
col = round(255*colorbarYLabelData.Color);
137+
colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col);
138138
colorbar.titlefont.size = 1.20 * colorbarYLabelData.FontSize;
139139
end
140140

@@ -178,16 +178,16 @@
178178

179179
%-coloration-%
180180
if isHG2
181-
col = 255*colorbarData.Color;
181+
col = round(255*colorbarData.Color);
182182
else
183183
if orientVert
184-
col = 255*colorbarData.YColor;
184+
col = round(255*colorbarData.YColor);
185185
else
186-
col = 255*colorbarData.XColor;
186+
col = round(255*colorbarData.XColor);
187187
end
188188
end
189189

190-
colorbarColor = sprintf('rgb(%f,%f,%f)', col);
190+
colorbarColor = sprintf("rgb(%d,%d,%d)", col);
191191

192192
colorbar.outlinecolor = colorbarColor;
193193
colorbar.tickcolor = colorbarColor;
@@ -319,12 +319,12 @@
319319
%-colorbar bg-color-%
320320
if ~isHG2
321321
if ~ischar(colorbarData.Color)
322-
col = 255*colorbarData.Color;
322+
col = round(255*colorbarData.Color);
323323
else
324-
col = 255*figureData.Color;
324+
col = round(255*figureData.Color);
325325
end
326326

327-
obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f)', col);
327+
obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", col);
328328
end
329329

330330
%---------------------------------------------------------------------%
@@ -344,11 +344,11 @@
344344
for n = 1:nticks-1
345345
col = 1-colorData(n);
346346
colorscale{m} = {colorIndex(n), ...
347-
sprintf('rgb(%f,%f,%f)', ...
348-
255*[col, col, col])};
347+
sprintf("rgb(%d,%d,%d)", ...
348+
round(255*[col, col, col]))};
349349
colorscale{m+1} = {colorIndex(n+1), ...
350-
sprintf('rgb(%f,%f,%f)', ...
351-
255*[col, col, col])};
350+
sprintf("rgb(%d,%d,%d)", ...
351+
round(255*[col, col, col]))};
352352
m = 2*n+1;
353353
end
354354
obj.data{colorbarDataIndex}.marker.color = colorbarData.Ticks;

plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
%---------------------------------------------------------------------%
4646

4747
%-font properties-%
48-
titleColor = sprintf('rgb(%f,%f,%f)', 255*titleStruct.Color);
48+
titleColor = sprintf("rgb(%d,%d,%d)", round(255*titleStruct.Color));
4949
titleSize = titleStruct.FontSize;
5050
titleFamily = matlab2plotlyfont(titleStruct.FontName);
5151

plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function UpdateGeoAxes(obj, geoIndex)
5858
if strcmpi(geoData.Grid, 'on')
5959
geoaxes.lataxis.showgrid = true;
6060
geoaxes.lataxis.gridwidth = geoData.LineWidth;
61-
geoaxes.lataxis.gridcolor = sprintf('rgba(%f,%f,%f,%f)', 255*geoData.GridColor, geoData.GridAlpha);
61+
geoaxes.lataxis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ...
62+
[round(255*geoData.GridColor) geoData.GridAlpha]);
6263
end
6364
end
6465

@@ -75,7 +76,8 @@ function UpdateGeoAxes(obj, geoIndex)
7576
if strcmpi(geoData.Grid, 'on')
7677
geoaxes.lonaxis.showgrid = true;
7778
geoaxes.lonaxis.gridwidth = geoData.LineWidth;
78-
geoaxes.lonaxis.gridcolor = sprintf('rgba(%f,%f,%f,%f)', 255*geoData.GridColor, geoData.GridAlpha);
79+
geoaxes.lonaxis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ...
80+
[round(255*geoData.GridColor) geoData.GridAlpha]);
7981
end
8082
end
8183

0 commit comments

Comments
 (0)