How to add top and bottom x-axes labels to a heatmap?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ct8
am 12 Jan. 2023
Beantwortet: Benjamin Kraus
am 22 Dez. 2023
I have a heatmap to which I want to add two x-axes, top and bottom, representing two different quantities. Attached are the .fig I got, and the source .mat.
0 Kommentare
Akzeptierte Antwort
Benjamin Kraus
am 22 Dez. 2023
If you check out this other question on MATLAB Answers: https://www.mathworks.com/matlabcentral/answers/378670-move-x-axis-labels-on-a-heatmap-to-the-top
My answer from November 8, 2023 shows how to leverage tiledlayout to create an axes that sits under the heatmap and can be used to add additional labels. This same technique can be used to add duplicate labels on the top and bottom of the heatmap. It has working example code you can start with.
0 Kommentare
Weitere Antworten (1)
Guilherme
am 12 Jan. 2023
Hi @ct8! I think you may want to have a look on this page: https://www.mathworks.com/help/matlab/creating_plots/graph-with-multiple-x-axes-and-y-axes.html#mw_ca4bd216-f46d-49cd-94ed-3fe176088b04
It shows how to add two axes to a single plot. Then, you'd need to use xlabel and reference the Xaxis that you want to change as the target. You'd need something like that:
t = tiledlayout(1,1);
target_bottom = axes(t);
%%
% Plot Bottom
%%
target_top = axes(t);
target_top.XAxisLocation = 'top';
%%
% Plot Top
%%
xlabel(target_bottom,'Bottom Axis')
xlabel(target_top,'Top Axis')
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!