Create Magnified Plot of Rectangular ROI on Same Figure

This function magnifies a specified rectangular area in the current figure, and plots the magnified area on the same figure.
283 Downloads
Updated 12 Feb 2021

View License

This function magnifies a specified rectangular area [xlm, ylm]
in the current figure,and plots the magnified area on the same figure at axis defined by
position pos

Inputs:
xlm = 1x2 vector specifying limits of x-axis
ylm = 1x2 vector specifying limits of y-axis
pos = 4x1 vector specifying position of new axis
lwid = linewidth of lines in magnified plot
showAxisLabels = boolean to turn axis labels on/off

Example usage:
x = 0:10; y1 = x; y2 = 3 - 0.5*x;
figure;
plot(0:10,y1,'k--','linewidth',2); hold on;
plot(0:10,y2,'ko-','linewidth',2); hold on;
axis square;
xlm = [1.5,2.5];
ylm = [1.5,2.5];
pos = [.25 .6 .25 .25]; % pos = [x0, y0, xwidth, ywidth]

magnifyPlot(xlm,ylm,pos,2,false) % call function

(c) Rishabh Datta, 2021-02-12

Cite As

Rishabh Datta (2024). Create Magnified Plot of Rectangular ROI on Same Figure (https://www.mathworks.com/matlabcentral/fileexchange/87332-create-magnified-plot-of-rectangular-roi-on-same-figure), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

magnifyPlot

Version Published Release Notes
1.0.1

Added example figure

1.0.0