フィルターのクリア

Subscripts and supercripts in heatmap axis labels

7 ビュー (過去 30 日間)
Raquel Nunes Palmeira
Raquel Nunes Palmeira 2019 年 3 月 15 日
回答済み: Benjamin Kraus 2023 年 9 月 20 日
Hi, I am having trouble adding subscripts and supercripts to the axis labels on my heatmap. At the moment my code looks like this:
heatmap(string(round(log10(range_par_N),2)),string(round(log10(range_par_C2),2)),heatmap_data_Nconc,'CellLabelColor','none','GridVisible','off');
colormap(parula);
xlabel('log K^{N}_{N}');
ylabel('log K^N _C2');
But the axis labels look like this:
Screen Shot 2019-03-15 at 09.55.00.png
I have also tried doing:
heatmap(string(round(log10(range_par_N),2)),string(round(log10(range_par_C2),2)),heatmap_data_Nconc,'CellLabelColor','none','GridVisible','off');
colormap(parula);
h = xlabel('log K^{N}_{N}');
set(h,'Interpreter','tex');
But I get the following error:
Error using matlab.graphics.chart.Chart/xlabel
Output arguments are not supported when using xlabel with heatmap.
Error in xlabel (line 32)
hh = xlabel(ax,args{:});
The subscript and supercript work fine in the 'tex' style for all my other plots, but doesn't work for heatmap. Is it just that these are not suported for heatmaps?
I am using version R2018b.
I am new at using Matlab, so apologies if I have missed something obvious.

採用された回答

Raquel Nunes Palmeira
Raquel Nunes Palmeira 2019 年 3 月 21 日
I haven't really found the answer for this through using 'heatmap', but a colleague told me that using 'surf' with the command view(0,90) gives an equivalent to heatmap, and this supports the subscripts and superscripts.
z = surf(round(log10(range_par_N),2),round(log10(range_par_C2),2),heatmap_data_div);
view(0,90);
d = colorbar;
z.EdgeColor = 'none';
xlabel('log K^{N}_{N}');
ylabel('log K_{C_2}^N');
d.Label.String = 'Number of protocell divisions per day at equilibrium';
d.Label.FontSize = 16;
set(gca,'FontSize',14);

その他の回答 (2 件)

Carly Cocke
Carly Cocke 2020 年 1 月 3 日
You can edit Adam Danz's fix/get around of manipulating the interpreter property to fix the title text:
and here's the editted version of his code to apply to yours:
h.heatmap(string(round(log10(range_par_N),2)),string(round(log10(range_par_C2),2)),heatmap_data_Nconc,'CellLabelColor','none','GridVisible','off');
colormap(parula);
a2 = axes('Position', h.Position); %new axis on top to add label's
a2.Color = 'none'; %new axis transparent
a2.YTick = []; %Remove ytick
a2.XTick = []; %Remove xtick
a2.YDir = 'Reverse'; %flip your y axis to correspond with heatmap's
xlabel('log K^{N}_{N}'); %you can use any commands under axes properties to edit the axes appearance
ylabel('log K_{C_2}^N');

Benjamin Kraus
Benjamin Kraus 2023 年 9 月 20 日
Starting in MATLAB R2023b, the HeatmapChart now has an Interpreter property.
h = heatmap(magic(4),'Interpreter','latex','CellLabelColor','none','GridVisible','off');
colormap(parula);
xlabel('$log K^{N}_{N}$');
ylabel('$log K^N_C2$');

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by