Live Editor can not perfectly preview figures with boldmath
code for reproducing the problem :
close all;
data = [1,1,1,1;2,2,2,2;3,3,3,3;4,4,4,4];
bar(data)
hold on
grid on
xticks([1 2 3 4])
xtickangle(0)
ax = gca;
ax.TickLabelInterpreter = ‘latex’;
xTicklabels = { …
‘textbf{label 1} boldmath$E_1$’, …
‘textbf{label 2} boldmath$E_2$’, …
‘textbf{label 3} boldmath$E_3$’, …
‘textbf{label 4} boldmath$E_4$’};
set(gca,’XTickLabel’,xTicklabels);
ax.YTickLabel = strcat(‘textbf{‘,ax.YTickLabel,’}’); % include this line
xlabel("Different algorithms");
ylabel("Result of schemes");
lgd = legend( …
"1",…
"2",…
"3",…
"4",…
‘Location’,"northwest");
lgd.FontWeight = "bold";
ax.XAxis.FontWeight = ‘bold’;
ax.XAxis.LineWidth = 1;
ax.YAxis.FontWeight = ‘bold’;
ax.YAxis.LineWidth = 1;
ax.FontName = ‘times’;
hold off;
The image above is the expected result. However, the result I obtained in the live editor is as follows:code for reproducing the problem :
close all;
data = [1,1,1,1;2,2,2,2;3,3,3,3;4,4,4,4];
bar(data)
hold on
grid on
xticks([1 2 3 4])
xtickangle(0)
ax = gca;
ax.TickLabelInterpreter = ‘latex’;
xTicklabels = { …
‘textbf{label 1} boldmath$E_1$’, …
‘textbf{label 2} boldmath$E_2$’, …
‘textbf{label 3} boldmath$E_3$’, …
‘textbf{label 4} boldmath$E_4$’};
set(gca,’XTickLabel’,xTicklabels);
ax.YTickLabel = strcat(‘textbf{‘,ax.YTickLabel,’}’); % include this line
xlabel("Different algorithms");
ylabel("Result of schemes");
lgd = legend( …
"1",…
"2",…
"3",…
"4",…
‘Location’,"northwest");
lgd.FontWeight = "bold";
ax.XAxis.FontWeight = ‘bold’;
ax.XAxis.LineWidth = 1;
ax.YAxis.FontWeight = ‘bold’;
ax.YAxis.LineWidth = 1;
ax.FontName = ‘times’;
hold off;
The image above is the expected result. However, the result I obtained in the live editor is as follows: code for reproducing the problem :
close all;
data = [1,1,1,1;2,2,2,2;3,3,3,3;4,4,4,4];
bar(data)
hold on
grid on
xticks([1 2 3 4])
xtickangle(0)
ax = gca;
ax.TickLabelInterpreter = ‘latex’;
xTicklabels = { …
‘textbf{label 1} boldmath$E_1$’, …
‘textbf{label 2} boldmath$E_2$’, …
‘textbf{label 3} boldmath$E_3$’, …
‘textbf{label 4} boldmath$E_4$’};
set(gca,’XTickLabel’,xTicklabels);
ax.YTickLabel = strcat(‘textbf{‘,ax.YTickLabel,’}’); % include this line
xlabel("Different algorithms");
ylabel("Result of schemes");
lgd = legend( …
"1",…
"2",…
"3",…
"4",…
‘Location’,"northwest");
lgd.FontWeight = "bold";
ax.XAxis.FontWeight = ‘bold’;
ax.XAxis.LineWidth = 1;
ax.YAxis.FontWeight = ‘bold’;
ax.YAxis.LineWidth = 1;
ax.FontName = ‘times’;
hold off;
The image above is the expected result. However, the result I obtained in the live editor is as follows: live editor MATLAB Answers — New Questions