How to zoom in the portion of the same contour as shown in figure
18 次查看(过去 30 天)
显示 更早的评论
i have made this contour using MATLAB.
THE Zoom in plot shown is created by using the figure tools manually
How can i do this using the Contourf command for the 25<Xcordinates<50 and 25<Ycordinates<50
i need to create 60 plots like this and zooming in isn't possible to perform manually
The main problem is how to plot a contour on top of another contour?
采纳的回答
Adam Danz
2020-1-21
编辑:Adam Danz
2020-1-24
The content of the subplot merely shows a subsection of the data; it is not 'zoomed' or rescaled.
You'll have to build this manually by following just a few steps.
1) Create a secondary axes within the primary axes.
clf()
axPrimary = axes('Units','Normalize','Box','on');
axSecondary = axes('Units','Normalize','Box','on');
scale = 0.45; % percentage of original size
axSecondary.Position(3:4) = scale * axSecondary.Position(3:4);
axSecondary.Position(1:2) = axPrimary.Position(1:2) + axPrimary.Position(3:4)*(1-scale);
2) Plot the contour as you normally would and specify the primary axis handle as the parent. Then plot the contour subsection by specifying which coordinates to plot and specify the secondary axis handle as the parent.
% Plot contour (it doesn't matter which syntax you use)
Z = peaks;
[~, ch] = contourf(axPrimary, Z);
% Choose section to isolate
xSection = [10, 25]; % x-bounds
ySection = [20, 35]; % y-bounds
% Get index values of section
xIdx = ch.XData >= xSection(1) & ch.XData <= xSection(2);
yIdx = ch.YData >= ySection(1) & ch.YData <= ySection(2);
% Plot section in secondary axis
[~,ch2] = contourf(axSecondary, ch.XData(xIdx), ch.YData(yIdx), ch.ZData(yIdx,xIdx))
ch2.LevelList = ch.LevelList;
caxis(axSecondary, caxis(axPrimary))
axis(axPrimary,'equal')
axis(axSecondary,'equal')
% Show the section in the main axis, if you want to.
rectangle(axPrimary,'Position',[xSection(1),ySection(1),range(xSection),range(ySection)])
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!