Hi,
I have a 3D plot that I generated with this code:
a= linspace(0.8,1.2,12);
surf(a,1:59,abs(Z_data),'FaceColor' , 'interp');
and I would like to display the black lines orthogonal to the X axis, but not for the ones orthogonal to the Y axis. I have seen that I can choose the line style for the whole surface, but can I choose a different line style for the different lines orthogonal to the X or Y axis? That is, I want to show each of the a values in the surface grid but not the 59 lines for the y values.
Further, could I label each of these lines orthogonal to the X axis (example like in the image) if I do this:
Thanks in advance for your help!

 採用された回答

jonas
jonas 2018 年 5 月 25 日

1 投票

As an alternative to waterfall, I just learned that you can change the meshstyle of surfaces
h=surf(peaks)
h.MeshStyle='row';

6 件のコメント

Auryn_
Auryn_ 2018 年 5 月 26 日
YES! Finally, thanks so much!
jonas
jonas 2018 年 5 月 26 日
I have played around a bit with labeling the lines. Here is my code so far:
figure;hold on
h=surf(peaks(20))
h.FaceAlpha=0.5
h.MeshStyle='row';
y=h.YData; x=h.XData; z=h.ZData;
ind=10; %specify location along x-axis
for i=1:length(y)
text(x(ind),y(i),z(ind,i),num2str(i));
end
You will have to adjust the code so that the end-result works for your own graph. I have used transparency to avoid issues with the label being behind the surface. Another solution (which may be best in your case) would be to put the labels at the end of the curves.
Auryn_
Auryn_ 2018 年 5 月 27 日
Thanks again!
How would you put the labels at the end of the curves?
jonas
jonas 2018 年 5 月 27 日
編集済み: jonas 2018 年 5 月 27 日
It depends on perspective. In the x-z plane you just plot all labels at x(end) or alternatively at x(end)+dx. In my example with peaks this is not a good idea, as all z are equal and the labels become stacked (see attachment). However, it may work nicely for you. Just play around with the indices.
dx=0;
for i=1:length(y)
ha(i)=text(x(end)+dx,y(i),z(i,end),num2str(i));
end
it's probably a good idea to save the handles as well (see ha above) so that you can access and alter their properties after the loop.
cheers
Auryn_
Auryn_ 2018 年 5 月 27 日
編集済み: Auryn_ 2018 年 5 月 27 日
Done!
dy=0;
for i=1:length(a)
ha(i)=text(x(i),y(end)+dy,z(i,end),num2str(a(i)));
end
Thank you very much for your time and support!
jonas
jonas 2018 年 5 月 27 日
No problem, happy to help!

サインインしてコメントする。

その他の回答 (2 件)

Steven Lord
Steven Lord 2018 年 5 月 25 日

0 投票

It sounds like you may want a waterfall plot.
Auryn_
Auryn_ 2018 年 5 月 26 日

0 投票

Now the second part of the question:
can I add labels on the lines orthogonal to the X axis?
Cheers!

2 件のコメント

jonas
jonas 2018 年 5 月 26 日
Right, forgot about that one. Ill edit my answer later today!
Auryn_
Auryn_ 2018 年 5 月 26 日
thanks ;)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2018 年 5 月 25 日

コメント済み:

2018 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by