How to change X and Y axis values on a heatmap.

141 vues (au cours des 30 derniers jours)
Myles Stapelberg
Myles Stapelberg le 14 Mai 2018
Modifié(e) : Benjamin Kraus le 26 Juil 2018
Hi.
So I have a heatmap, that displays a 50 x 50 array of values. I want the X and Y Axis to go from 1 to 10 (with each value representing 5 of the previous), but right now, since I have a 50 x 50 array, each axis goes from 1-50. This is unsightly and I wan't to change this.
I have tried changing the XDispayLabel and YDisplayLabel in code, and in the editor after creating the heatmap, but to no avail.I kept on getting an error message saying that the cell was out of the dimensions of XDisplay or YDisplay.
Another question (Albeit, less important) is how to choose colors that are a bit easier to differentiate from, and how to set the limit of the colors to custom limits, since my values are very close together and are getting grouped up accordingly. I am running R2018a. Here is my code for the Heat map:
if true
% code
%heatmap
h = heatmap(total_cost, 'Colormap', parula(20), 'ColorbarVisible', 'on', 'XLabel', 'Installed MW of Solar (1000MW per Tick)', 'YLabel', 'Installed MW of Wind(1000MW per Tick)');
h.title(['Optimal Mix of Wind and Solar', 'FontSize', 30]);
h.xlabel(['Installed MW of Solar (1000MW per Tick)', 'FontSize', 24]);
h.ylabel(['Installed MW of Wind (1000MW per Tick)', 'FontSize', 24]);
h.XDisplayLabel[1:10:100];
h.YDisplayLabel[1:10:100];
end
Thank you in advance.

Réponse acceptée

Aditya Salveru
Aditya Salveru le 14 Mai 2018
Modifié(e) : Aditya Salveru le 15 Mai 2018
Hi Myles,
You can change the x axis and y axis values by providing them as input to heatmap.
Create numemric arrays x,y within the range required and provide them as arguments.
x=linspace(1,10,50);
y=linspace(1,10,50);
h = heatmap(x,y,total_cost, 'Colormap', parula(20), 'ColorbarVisible', 'on', 'XLabel', 'Installed MW of Solar (1000MW per Tick)', 'YLabel', 'Installed MW of Wind(1000MW per Tick)');
I am attaching the snapshot of a heatmap with 50x50 random values with x and y axis normalized to 1-10.
Thanks,
Aditya
  2 commentaires
Myles Stapelberg
Myles Stapelberg le 14 Mai 2018
Hello Aditya,
Thank you for your response. I just tried your method, and while I was able to scale down the axis, I still have decimal numbers in between the whole numbers on the axis.
Is there a way to only display the whole numbers? The less clutter on this heatmap the better!
Thank you in advance.
Myles
Aditya Salveru
Aditya Salveru le 15 Mai 2018
Hi,
I think you can use 'round' function to round off the decimal digits of x and y to 1 or 2 digits and it may look better.
Thanks.

Connectez-vous pour commenter.

Plus de réponses (1)

Benjamin Kraus
Benjamin Kraus le 26 Juil 2018
Modifié(e) : Benjamin Kraus le 26 Juil 2018
Sorry I'm late to this question, but in case you are still looking for an answer to your second question ("Another question is how to choose colors that are a bit easier to differentiate from, and how to set the limit of the colors to custom limits, since my values are very close together and are getting grouped up accordingly."):
You can try the ColorScaling property. Setting the value to log may help you better differentiate your data.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by