3D Plot with Four Variables

2 次查看(过去 30 天)
Hello, I have four variables (Demand, NPV_all, STD_all, STD_In) and I would like to plot them in a 3D plot. I have created the plot but for some reason I can not show the legend. Can anyone help please.
if true
Demand = rand(7,3);
NPV_all = rand(7,3);
STD_all = rand(7,3);
STD_In = [0.25 .5 .75] .* ones(7,3);
Demand_V = Demand(:);
NPV_V = NPV_all(:);
STD_V = STD_All(:);
STD_In_V = STD_In(:);
h = scatter3(Demand_V,STD_V,NPV_V,markerSize,STD_In_V,'filled');
title('Economic Impact of Production Profile')
xlabel('Demand [MMSCFD]')
ylabel('STD [$B]')
zlabel('NPV [$B]')
legend('STD = 0.25', 'STD = 0.50','STD = 0.75');
end

采纳的回答

KSSV
KSSV 2018-9-24
Demand = rand(7,3);
NPV_all = rand(7,3);
STD_all = rand(7,3);
STD_In = [0.25 .5 .75] .* ones(7,3);
Demand_V = Demand(:);
NPV_V = NPV_all(:);
STD_V = STD_all(:);
STD_In_V = STD_In(:);
markerSize = 10 ;
STD = [0.25 0.50 0.75] ;
figure
hold on
for i = 1:length(STD)
idx = abs(STD_In_V-STD(i))<=10^-3 ;
h = scatter3(Demand_V(idx),STD_V(idx),NPV_V(idx),markerSize,STD_In_V(idx),'filled');
end
title('Economic Impact of Production Profile')
xlabel('Demand [MMSCFD]')
ylabel('STD [$B]')
zlabel('NPV [$B]')
legend('STD = 0.25', 'STD = 0.50','STD = 0.75');
  1 个评论
Yaser Khojah
Yaser Khojah 2018-9-24
编辑:Yaser Khojah 2018-9-24
Thanks so much for your help and that is what I was looking for. Would it be possible to connect these dots? For example all the dots belong to 0.25?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by