Hello all,
I am creating a surface plot, and plotting on top of this a quiver plot. Everything works great, however where I have large "z" values on my surface plot, the quiver arrows are being hidden by the graph.
Any ideas how to solve this? I have attached an image of my problem, look at the yellow boxes, where the quiver arrows are hidden.

 채택된 답변

Star Strider
Star Strider 2019년 4월 24일

0 개 추천

I was considering something like this:
x = linspace(-pi, pi, 20);
h = x(2)-x(1);
[X,Y] = ndgrid(x);
Z = sin(X) .* cos(Y);
[U,V] = gradient(Z,h,h);
W = zeros(size(U));
figure
surf(X, Y, Z)
hold on
quiver3(X,Y,Z, U,V,W, 0.7, 'r')
hold off
shading('interp')
grid on
view(0, 90)
All the arrows are visible because they all plot with respect to ‘Z’. The ‘W’ matrix simply makes them plot in a plane. (I made them red so they’re more visible.)

댓글 수: 2

Mark Lepage
Mark Lepage 2019년 4월 24일
Thank you very much, this has effectively solved my problem, and produced a much nicer graph.
Could you please explain a little more how to implement the z-offset on the quiver plot.
I believe 100% that this is the problem.
I appreciate your help a lot.
Star Strider
Star Strider 2019년 4월 24일
My pleasure.
The Z-offset is simply the zeros ‘W’ matrix that effectively plots the arrows on top of the surf plot. Instead of 3D quiver arrows, the ‘W’ matrix creates the arrows as a 2D plane, however with their origins on the ‘Z’ values of the surf plot. You can see this by using the GUI (‘Tools’ -> ‘Rotate 3D’) or the view function to rotate the plot to see the arrows with respect to the ‘Z’ surface elevation. They all plot above it, regardless of where they originate.
That’s probably as well as I can explain it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Thomas Rosin
Thomas Rosin 2019년 4월 24일

0 개 추천

I don't think there are hidden, I just think your arrow size is too small.
The tip of the arrow scale with its length but it's a parameters you can set on the quiver function.

댓글 수: 6

Mark Lepage
Mark Lepage 2019년 4월 24일
Thanks for your answer Thomas,
When I simply rotate the graph (for display purposes I don't want to do this), the quivers become visible.
Star Strider
Star Strider 2019년 4월 24일
If you don’t need the gridlines on your surf plot, you can set ‘EdgeColor’ (link) to be 'none' or 'interp', and you can set shading (link) to interp as well.
Either of those would likely make the arrows more visible.
Mark Lepage
Mark Lepage 2019년 4월 24일
Thanks for the answer, this does look much better and easier to visualize.
However, the middle arrows are still missing! Any ideas for this?
Star Strider
Star Strider 2019년 4월 24일
My pleasure.
However, the middle arrows are still missing! Any ideas for this?
Not really. I have no idea what you’re doing.
So I’m guessing here. One possibility is to plot the surf plot first, and the quiver plot afterwards. Another might be to add a ‘z’ coordinate to the quiver plot (perhaps the ‘z’ values of the surf plot, or plot the arrows on a plane higher than the maximum ‘z’ value of the surf plot) so that the arrows plot above the surf plot.
Mark Lepage
Mark Lepage 2019년 4월 25일
Just wanted to show you the improvement in my chart.
Capture.PNG
Much appreciated.
Star Strider
Star Strider 2019년 4월 25일
@Mark Lepage —
As always, my pleasure.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2019년 4월 24일

댓글:

2019년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by