Histogram or heatmap with self-defined values.

Hello all,
I would like to have a heatmap or histogram 2D (whichever works better) that plots values in the boxes I specify.
Example:
X = [1;2;3];
Y = [10;20;30];
mainvalue = [4;76;8];
array = [X,Y,mainvalue];
So if X has the value 2 and Y has the value 20, for example, then mainvalue has the value 76.
Basically I try to change the height of the bins with fixed values from a vector (here mainvalue).
This is how it should look, except that the bins contain the values of mainvalue:
Axis labeling does not match example!

댓글 수: 4

Your 3x1 vectors x, y, and mainvalue are not sufficient for a 2D heatmap or bivariate histogram. In these cases, you would need a 3x3 matrix of mainvalue data so that each pair of (x,y) has a value. What you describe are data along the diagonal but no other values off of the diagonal.
Example:
x = [1 2 3];
y = [5 6 7];
data = rand(3)
data = 3×3
0.6830 0.6347 0.0026 0.8265 0.4307 0.8139 0.5230 0.0823 0.0965
heatmap(x,y,data)
Okay that helps!! Thank you Adam.
But in that case is there no option how to display the data with a vector like in my example image?
So that each x and y value is also assigned a mainvalue value and I then plot this as a box in the histogram?
I've replied with an answer below.

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

 채택된 답변

Adam Danz
Adam Danz 2022년 10월 7일
편집: Adam Danz 2022년 10월 7일
You have (x,y) coordinates and my interpretation is that you'd like to use color or another property to represent a third value mainvalue. One option is a scatter plot:
X = [1;2;3];
Y = [10;20;30];
mainvalue = [4;76;8];
scatter(X,Y,100,mainvalue,'filled'); % 3rd arg defines size
cb = colorbar();
ylabel(cb, 'mainvalue')
axis padded
box on
grid on

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 10월 6일

편집:

2022년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by