Azzera filtri
Azzera filtri

Tex Markup Ignored Even When Tex Interpreter is Manually Set

22 visualizzazioni (ultimi 30 giorni)
Grace Steward
Grace Steward il 3 Lug 2024 alle 22:13
Spostato: Walter Roberson il 4 Lug 2024 alle 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 Commento
Walter Roberson
Walter Roberson il 3 Lug 2024 alle 22:50
You might need to enclose your tex code in $$
xlabelstr = '$/color{black}Charity Donation (\$)$';
ylabelstr = '$/color{black}Shock Units (U)$';

Accedi per commentare.

Risposte (1)

Jeff Miller
Jeff Miller il 3 Lug 2024 alle 23:39
Spostato: Walter Roberson il 4 Lug 2024 alle 4:56
Shouldn't your forward slashes be backslashes? Try, e.g.
'\color'
instead of
'/color'
etc

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by