How to do 3D plot using both contourf and surf plot?
Ältere Kommentare anzeigen
Hello matlab community,
I have two datasets ( Z = index and data=observation data) , both are 2D matrix and have different max/min.Both are defined at same X and Y location (this two also 2D matrix).
I want to show both this data in a 3d plot using surf and contourf command.
I have tried with the given code below and have shown you a plot that I am getting.I want to show both this data in a 3d plot using surf and contourf command.I want to plot a surface plot (to show 3d distribution) of the given "data" at the top of the index (Z data). That is 3d distribution of "data" and at z=0 I want to show the index data (Z data). So at xy plane (at z=0) of 3d distribution of "data", I want to plot the contourf of Index data.
I have tried with the code and have sown you a plot that I am getting (1st figure). You can see two plots are there in the figure i just want "pink and blue contourf" plot at z=0 of the other plot. (don't need to show xticks,zticks,yticks of contourf as both X,Y are same for two figure). I want a figure like the attached screenshot. I have also attached the data for better clarity of my question.
f=figure('color','w');
ax1 = axes;
surf(ax1,X(1:skip:end,1:skip:end,i),Y(1:skip:end,1:skip:end,i),data(1:skip:end,1:skip:end),data(1:skip:end,1:skip:end),'FaceAlpha',0.9, 'FaceColor','flat','EdgeColor','none');
xlim([0,76])
view(2)
colormap(ax1,'jet')
view(-15,50)
%shading interp
hold on
ax2 = axes;
contourf(ax2,X(1:skip:end,1:skip:end,i),Y(1:skip:end,1:skip:end,i),squeeze(Z(1:skip:end,1:skip:end,i)),'EdgeColor','none')
colormap(ax2,flipud(rgb))
xlim([0,76])
zticks([])
view(-15,150)
%linkaxes([ax1,ax2]);
axis equal
% Link two axes together
hLink = linkprop([ax1,ax2],{'XLim','YLim','ZLim','CameraUpVector','CameraPosition','CameraTarget'});
Any help would be appreciated and many thanks in advance.
Akzeptierte Antwort
Weitere Antworten (1)
ONKAR
am 1 Jun. 2023
Obtain the 3 dimensional plot for following function using matlab z=(sin(underroot(x^2+y^2)))/(underroot(x^2+y^2)),-6<=x<=6, -6<=y<=6.
Kategorien
Mehr zu Contour Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


