How to make a surface plot with colors for three variables
Show older comments
I want to plot how the increase in power demand AAG of households relates to the number of inhabitants AAI. I have 36 houses and investigates the increase for the combinations of 1,2,3...36 houses (y)
I have tried making plots, but the only thing I can come up with is scatter plots, but then the number of households. Since I combine 2,3,4... 36 households I will have 36 scatter plots if I do like this
but I want one 2D surface plot with colors. Inserted the data for 1 and 2 households to make things more clear.
for y=1:2
xx=cell(length(AAG{y}),1);
I=cell(length(AAG{y}),1);
for o=1:length(AAG{y})
xx{o} =AAG{y}{o};
I{o}=AAI{y}(o);
end
for k1 = 1:length(AAG{y})
scatter(ones(1,numel(xx{k1}))*y, xx{k1},ones(1,numel(xx{k1}))*I{k1},'s','Linewidth',10)
end
end
colormap(parula(100));
colorbar;
h=colorbar;
ylabel(h, 'Number of inhabitants')
caxis([2 10])
ylim([0 20])
xlim([0 3])
xlabel('Nr of households being combined')
ylabel('Increase in rated power')
3 Comments
Jan
on 24 Apr 2021
"I have 36 houses and Im investigating what happens with the power demand if Electric vehicles."
You are not a newcomer in this forum anymore. Remember, that for Matlab all these data are simply numbers. Therefore for the solution the detail of the meaning of the variables is not needed. Therefore explaining these details are a waste of time.
"I will have three column vectors of the size 36000x1"
This sounds useful.
"A - how many houses are randomly selected? In this case A consists of 36000 ones
B - How many inhabitants live in the house? There are 36 values which are repeated 1000 times to match the size of C
C- How much the power demand increase for a certain"
I do not understand, what these 3 points mean. I cannot answer the question "how many houses are randomly selected?" and I do not see, how this question can be a "case". It is not getting clear to me, what you are asking for.
Steven Lord
on 24 Apr 2021
Show us what you mean with a concrete but smaller data set. Generate a synthetic group of say 4-6 houses and describe using the data for those houses what you're trying to do. It could be that by writing the explanation for the smaller data set you'll answer your own questions (a version of rubber duck debugging that's more like rubber duck designing.) If not seeing the problem described in the concrete rather than the abstract may help us better understand so we can better help you.
Sinmplify your code:
% Replace:
xx=cell(length(AAG{y}),1);
I=cell(length(AAG{y}),1);
for o=1:length(AAG{y})
xx{o} =AAG{y}{o};
I{o}=AAI{y}(o); % Do you really want a nested cell?
end
% by:
xx = AGG{y};
I = AAI{y};
The actual question is still not getting clear.
Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!