필터 지우기
필터 지우기

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

조회 수: 87 (최근 30일)
Myles Stapelberg
Myles Stapelberg 2018년 5월 14일
편집: Benjamin Kraus 2018년 7월 26일
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.

채택된 답변

Aditya Salveru
Aditya Salveru 2018년 5월 14일
편집: Aditya Salveru 2018년 5월 15일
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
Myles Stapelberg
Myles Stapelberg 2018년 5월 14일
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 2018년 5월 15일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Benjamin Kraus
Benjamin Kraus 2018년 7월 26일
편집: Benjamin Kraus 2018년 7월 26일
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.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by