How to create 3d figures as follows

1 回表示 (過去 30 日間)
student_md
student_md 2021 年 3 月 4 日
編集済み: Cris LaPierre 2021 年 3 月 6 日
I can lively modify my 3d plots on plots editor, but I want to modify on Editor by codes.
Suppose that we have two figures p1 and p2 as follows:
close all;
clc;
clear all;
[X,Y] = meshgrid(-5:.5:5);
Z = Y.*sin(X) - X.*cos(Y);
p1 = surf(X,Y,Z);
hold on
p2 = surf(X,Y,Z);
I want to achive followings:
-p1 should be red sphere and markersize=12.
-p2 should be turquoise color and linestyle=none.
-axes gridlinestyle should be '-.' and axes gridline color=blue.
-Can legends be placed in a specific coordinate like (x=2,y=5,z=8)?
Consequently, I want to get a figure similar to the following:

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 5 日
編集済み: Cris LaPierre 2021 年 3 月 6 日
Once you know the property names, it's just a matter of setting the desired value. It does seem your equation creates a different shape from the one you show in your image.
[X,Y] = meshgrid(-5:.5:5);
Z = Y.*sin(X) - X.*cos(Y);
p1 = surf(X,Y,Z,"FaceColor","none",...
"Marker","o","MarkerEdgeColor","y",...
"MarkerFaceColor","r",'MarkerSize',12,...
"EdgeColor","none","DisplayName","data2");
hold on
p2 = surf(X,Y,Z,"FaceColor",[0.25 0.8750 0.8125],...
"EdgeColor","none","DisplayName","data1");
hold off
grid on % grid is on by default, so not necessary
ax=gca;
ax.GridColor='b';
ax.GridLineStyle = '-'; % this is the default, so not necessary
% first input uses suface objects to set order lines appear.
legend([p2,p1],"Location","north")
xlabel("x")
ylabel("t")
zlabel("v(x,t)")

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by