Two surf plots on one figure - matlab

I want to plot on top of one surf graph another surf graph. This is the code.
x1=0:0.01:1;
y1=0:0.01:1;
[X,Y]=meshgrid(x1,y1);
Z=(X.*Y)./(X+Y-(X.*Y));
surf(X,Y,Z)
hold on;
[X1,Y1]=meshgrid(x,y);
Z1=(X1.*Y1)./(X1+Y1-(X1.*Y1));
surf(X1,Y1,Z1,'FaceColor', 'black','EdgeColor','none');
And in the graph I get how can I make the surf(X1,Y1,Z1,'FaceColor', 'black','EdgeColor','none'); more visible. In working with plots there's the option to change marker size and marker type. Is there are a similar thing for surf graph?
In the graph below I want to make the circled area more visible. Is there a way like to increase the marker size in surf graphs? Or to reduce the colour of the first surf plot a bit.

Related

How to place a geographical map underneath a surf plot in Matlab?

If there is an easier way to do this in general any suggestions would be appreciated.
I have imported a .nc file into Matlab and currently have a surface plot created from the interpolated matrix of data which corresponds to longitudes and latitudes. An alpha scale has been applied to add opacity and now I would like to place a map of said longs and lats beneath it so that it acts as an overlay.
here is the code used to plot where xq,yq is the mesh longitude and latitude grid and newMatrix is the interpolated version of the original matrix. Attached is the top view surf plot which I would like a map of long lat restricted x,y axis beneath (line style or topographic)
f = figure;
ax = axes('Parent',f);
h = surf(xq,yq,newMatrix,'Parent',ax);
set(h, 'edgecolor','none');
view(ax,[0,90]);
alpha color
alpha scaled
grid off
colorbar;
I'm aware of geomap but I'm not sure how it can be used in this way without causing the axis to misalign or just not be applied correctly. Before I was using a contour plot but found it easier to interpolate and plot with surf as per this post: Matlab how to make smooth contour plot?

Tick marks in a surface plot in matlab

I am trying to plot a surface plot in matlab using the code below.
f=figure('units','inches','Position',[0 0 5 10]);
ax=axes('Parent',f);
h=surf(X,Y,Z,'Parent',ax);
set(gca,'box','on');
The plot shows the tick labels but does not generate the tick marks inside the plot. This problem goes away when I replace the surf command with contourf in matlab. But I would like to know if there is a specific way to get the tick marks while using the surf option in matlab. Thanks in advance for help.
surf is actually a 3-dimensional object. If you view the plot from a 2D view (i.e. xy plane), then it's possible that the surface is covering the tick marks on the axes.
contourf is just a 2D object that is plotted beneath the tick marks.
Try replacing surf with pcolor, which should give the same result from a 2D view and not covering the tick marks.

How to plot a figure like this?

How to plot a figure like this
The data is like f(x_i,t_j), i=1,2,..,M, j=1,2,...,N. The horizontal axis is time t and vertical axis is space x
I know that mesh gives a 3-D plot and surf also gives 3-D surface, I wonder which command can give the above 2-D figure?
To make a 2D heatmap, display your array as an image using imshow, and add a colorbar.

How do I add 2 Y axis to my MATLAB Plot?

I know this question has been asked before - but none of them deal with a 3D plot with 2 Y axis. My question is a continuation of - How do I add a 2D Plot along with a surface or mesh plot in MATLAB? or this.
I have now successfully managed to add a 2D plot along with a surface plot. See image below -
Now my problem is that the range of the 2D plot is so high that the 3D plot is shrunk to look like nothing more than a plane on the ceiling. It is supposed to have variations like the figure in the question I have lined above.
How do I provide a different Y axis for the 2D plot so that the 3D plot is not shrunk like it is here.
It's possible that you can use the DataAspectRatio property to accomplish this. Taking inspiration from the example from the previous post, if we have:
z=peaks(100);
x1=linspace(0,100);
plot3(x1,0*ones(1,numel(x1)),40*sin(x1))
surface(z+40, 'edgecolor', 'none');
and then you can use
set( gca, 'dataaspectratio', [1.25 1.25 .7] )
view( [-37.5 18] )
can work in some cases to help regain some of the range on the surface plot. This method won't work, however, in very extreme cases.

How to visualize a 3d scene using surf

I have an image loaded from disk as a texture, and a same-sized matrix d which has the corresponding depths.
How can I use surf to show me the image as a 3d-model? Simply taking
surf(depthMatrix, img);
doesn't give a nice result since
the camera looks not from the x-y plane in z-direction
It looks fairly black
It doesn't look that smooth although my depth matrix is actually smoothed out when I show it using imshow(depthMatrix, []);
You can use texture mapping to display your image on your surface like so:
surf(depthMatrix,img,... %# depthMatrix is z data, img is an image
'FaceColor','texturemap',... %# Use texture mapping
'EdgeColor','none'); %# Turn off edge coloring
And to address your 3 points:
You can adjust your camera angle with the mouse by pressing the button on the figure, which turns on interactive 3-D rotation. You can also turn interactive rotation on using the function ROTATE3D, or you can change the camera view without the mouse using the function VIEW.
Your plot was looking black because edges are drawn as black lines by default, and there were probably a lot of them.
You can adjust the axis scaling and limits to make your surface appear smoother. For example, axis equal will make data units the same for all 3 axes, so your z axis (which ranges from 0 to 25) will be flattened significantly since your other two axes span ranges in the hundreds. Alternatively, in your call to SURF you can specify x and y data to use for the values on those axes, which can ultimately help you to better adjust the relative scaling between those axes and the z axis.