Effacer les filtres
Effacer les filtres

Tex Markup Ignored Even When Tex Interpreter is Manually Set

22 vues (au cours des 30 derniers jours)
Grace Steward
Grace Steward le 3 Juil 2024 à 22:13
Déplacé(e) : Walter Roberson le 4 Juil 2024 à 4:56
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 commentaire
Walter Roberson
Walter Roberson le 3 Juil 2024 à 22:50
You might need to enclose your tex code in $$
xlabelstr = '$/color{black}Charity Donation (\$)$';
ylabelstr = '$/color{black}Shock Units (U)$';

Connectez-vous pour commenter.

Réponses (1)

Jeff Miller
Jeff Miller le 3 Juil 2024 à 23:39
Déplacé(e) : Walter Roberson le 4 Juil 2024 à 4:56
Shouldn't your forward slashes be backslashes? Try, e.g.
'\color'
instead of
'/color'
etc

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by