Extending the curtain plot (reference plane) when 3D plotting with meshz

2 views (last 30 days)
Hi all,
I am using to meshz to display a 3D plot, but the curtain only extends to the extrema of the data points. In this particular case, the curtain falls inconveniently above the height 0.
Is it possible to drop the curtain to a specified height, namely 0? If so, how?
-Thanks,
Hussain

Accepted Answer

the cyclist
the cyclist on 23 Aug 2011
The values you want are stored in the "ZData" property of the plot. So, you need to grab those data, modify them, and set them again. The code below is something like what you need, although I am not 100% I understood whether you wanted to cut off below or above zero, so you might need to adjust things.
oldZData = get(get(gca,'Children'),'ZData')
newZData = min(0,oldZData);
set(get(gca,'Children'),'ZData',newZData)
EDIT IN RESPONSE TO COMMENT:
oldZData = get(get(gca,'Children'),'ZData');
newZData = oldZData;
newZData(min(oldZData(:))==oldZData) = 0;
set(get(gca,'Children'),'ZData',newZData)
  3 Comments
the cyclist
the cyclist on 24 Aug 2011
OK. I think I understand. I have added some different code to my answer, that I think does what you want. It identifies the points that are at the bottom of the current curtain, replaces those points with zeros, and redraws the new curtain.
Hussain
Hussain on 24 Aug 2011
Thanks! Your suggestion mostly solves the problem; it certainly pulls the curtain down to zero as I had hoped. However, by setting the minimum data point (or any data point for that matter) to zero, the presented data also has a false 0.
I managed to solve the problem in sort of a one-time-use-be-very-careful way by examining the meshz routine. The original programmer conveniently marked where the position of the curtain is defined, zref, as the minimum of a the finite z matrix. I made a modified copy of the routine in which zref = 0, which does the trick very cleanly in this case.
Thanks for your help! Your answer motivated my investigation into the meshz routine.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!