Tex Markup Ignored Even When Tex Interpreter is Manually Set
22 ビュー (過去 30 日間)
古いコメントを表示
Previously, I have been able to change the color of my y and x axis labels and tick labels using the tex interpreter syntax. I needed to do it like this because I did not want the black axis lines on my heatmap plot. So I built a code using tex markup, that used to output a figure that looked like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1727086/image.png)
However, now that figure when generated looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1727091/image.png)
If I change the window background color, it shows that my text is not being interpreted properly with the 'Tex' interpreter.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1727096/image.png)
This is despite my TickLabelInterpreter being set to 'tex'.
Any ideas what could be causing this sudden change/hiccup? A code snippet is below:
%% Figure 2 - Heatmaps of Acceptance Rates by $ to Subj and Contrasts
%Unpaid Phase
%Set Figure Environment
fig2A = figure;
fig2A.Units = 'inches';
fig2A.Position = [fig2A.Position(1), fig2A.Position(2), 6, 6.75];
fig2A.Color = 'white';
angle = 45;
xlabelstr = '/color{black}Charity Donation ($)';
ylabelstr = '/color{black}Shock Units (U)';
tl = tiledlayout(4,4, 'TileSpacing', 'compact', 'Padding', 'compact');
tl.Position(1) = 0.0875;
tl.Position(3) = 0.7625;
%Open Subplot
nexttile
ARheatmap{1} = imagesc(flipud(All.meanARbySubj{1}), [0 1]);
ax{2,1} = tl.Children(1);
ax{2,1}.XTick = 1:6;
ax{2,1}.Box = 'off';
ax{2,1}.XColor = 'w';
ax{2,1}.YColor = 'w';
title('Unpaid');
xticklabelstr = num2cellstr(CharVal);
yticklabelstr = num2cellstr(flip(ShockVal));
%Create ticklabel cell arrays
for i = 1:6
xticklabelstr{i} = ['/color{black}' xticklabelstr{i}];
if i < 6
yticklabelstr{i} = ['/color{black}' yticklabelstr{i}];
end
end
%Set Tick and axis labels
ax{2,1}.XTickLabel = xticklabelstr;
ax{2,1}.YTickLabel = yticklabelstr;
ax{2,1}.TickLabelInterpreter = 'tex';
xtickangle(angle);
xlabel(xlabelstr, 'Interpreter','tex');
ylabel(ylabelstr, 'Interpreter','tex');
%Add colorbar
colormap(plasma)
cb = colorbar;
cb.Color = 'w';
cb.Location = 'layout';
cb.Layout.Tile = 2;
cb.Ticks = [0 0.25 0.5 0.75 1];
cb.TickLabels = {'/color{black}0', '/color{black}0.25', ...
'/color{black}0.5', '/color{black}0.75', '/color{black}1'};
cb.Label.String = '/color{black}Shock Acceptance Rate';
cb.Box = 'off';
cb.TickLabelInterpreter = 'tex';
1 件のコメント
Walter Roberson
2024 年 7 月 3 日 22:50
You might need to enclose your tex code in $$
xlabelstr = '$/color{black}Charity Donation (\$)$';
ylabelstr = '$/color{black}Shock Units (U)$';
回答 (1 件)
Jeff Miller
2024 年 7 月 3 日 23:39
移動済み: Walter Roberson
2024 年 7 月 4 日 4:56
Shouldn't your forward slashes be backslashes? Try, e.g.
'\color'
instead of
'/color'
etc
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!