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:
However, now that figure when generated looks like this:
If I change the window background color, it shows that my text is not being interpreted properly with the 'Tex' interpreter.
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!