How do you plot a line of constant value on a surface plot?

31 ビュー (過去 30 日間)
Jacob Forsyth
Jacob Forsyth 2021 年 9 月 20 日
コメント済み: Star Strider 2021 年 9 月 20 日
I'm working on using surface plots to show data gathered in 3-d (longitude, latitude, depth). Is there a way to highlight a specific contour line on a surface plot?
In 2-d, I would typically use contourf(x,y,v,'linecolor','none') and contour(x,y,v,[30 30]) if I wanted to highlight the value 30.

回答 (1 件)

Star Strider
Star Strider 2021 年 9 月 20 日
See if contour3 or contour3m will do what you want.
[X,Y,Z] = peaks(30);
figure
surf(X,Y,Z)
hold on
contour3(X,Y,Z,[1 1]*pi, '-r', 'LineWidth',2)
hold off
grid on
Experiment with the appropriate function with your data and surface plot.
.
  2 件のコメント
Jacob Forsyth
Jacob Forsyth 2021 年 9 月 20 日
Thanks for the response. This is mostly what I would want except I wasn't fully clear on how I was using surf and what my data is. I am plotting a property which was measured in, x y and z. My current code now looks like this, but contour3 step has an error here. In this example I am trying to highlight the 1490 contour line. Is there a way for contour3 to work for this type of work?
surf(x_plot,y_plot,z_plot,ss,'edgecolor','none')
hold on
contour3(x_plot,y_plot,z_plot,ss,[1490 1490],'k') %this would be the step to replace to plot a constant contour
zlim([0 100])
colorbar
set(gca,'zdir','reverse')
view(-35,50)
caxis([1480 1520])
xlabel('Longitude')
ylabel('Latitude')
title('Sound Speed (m/s) May 18 2021')
Star Strider
Star Strider 2021 年 9 月 20 日
I have no idea what the ‘ss’ argument is. That may work as a colour argument for surf, however it is not appropriate for contour3.
It will probably work without ‘ss’, whatever it is:
contour3(x_plot,y_plot,z_plot,[1490 1490],'k') %this would be the step to replace to plot a constant contour
.

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

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by