How to zoom in the portion of the same contour as shown in figure
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
Réponse acceptée
Adam Danz
le 21 Jan 2020
Modifié(e) : Adam Danz
le 24 Jan 2020
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!