Borrar filtros
Borrar filtros

How to create a rectangle to locate a zooming area in a plot?

41 visualizaciones (últimos 30 días)
Hi guys!
I created an additional box within my figure to zoom a particular area of interest. I put this box in a position as desired. Now I want to create a rectangle within my figure to identify the coordinates of the zoom.
I want to get something like the blue rectangle in the following figure:
Can you help me?
Here is my script and attached to this post the required files:
%Planar Lyapunov Orbits (SE system, L1 point)
clear all; close all; clc;
%Data import
% Definition of path names and file names
Input_path_Fortran = 'D:\OneDrive\MSc_Thesis\Projects\Planar_Lyapunov_orbits\InputFiles\';
Output_path_Fortran = 'D:\OneDrive\MSc_Thesis\Projects\Planar_Lyapunov_orbits\OutputFiles\';
filename_Ly_orb = 'Planar_Lyapunov_SE_L1.txt';
filename_Ly_orb_selected = 'Planar_Lyapunov_SE_L1_evenly_spaced.txt';
%Import original database containing 4182 orbits
Ly_orb = import_txt_file([Input_path_Fortran,filename_Ly_orb],1,inf);
%Import filtered data containing 50 orbits
Ly_orb_sel = import_txt_file([Output_path_Fortran,filename_Ly_orb_selected],2,inf);
% Trova un modo per trasferire le opzioni di grafica di una figura a
% un'altra senza ripetere i comandi all'interno del plot (color, marker, et..)
,my_cyan,'MarkerSize',2); hold on
,my_red,'MarkerSize',8); hold on
grid off;
ylabel('$Jacobi\ Constant$','interpreter','latex','FontSize',12);
lgd = legend('$Original\ database$','$Filtered\ database$',...
lgd.Interpreter = 'latex';
lgd.FontSize = 11;
% Zoom on a casual portion of figure to show the equally spaced Jacobi constant values
axes('position',[.63 .16 .25 .25])
box on % put box around new pair of axes
x_min = -0.9930;
x_max = -0.9925;
indexOfInterest = (Ly_orb.x0 < x_max) & (Ly_orb.x0 > x_min);
indexOfInterest_sel = (Ly_orb_sel.x0 < x_max) & (Ly_orb_sel.x0 > x_min);
'.','color',my_cyan,'MarkerFaceColor',my_cyan,'MarkerSize',2); hold on
'.','color',my_red,'MarkerFaceColor',my_orange,'MarkerSize',8); hold on
axis tight

Respuesta aceptada

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh el 26 de Feb. de 2022
in first axes use function rectangle.
y_min = min(Ly_orb.JacobiConstant(indexOfInterest)); % need indexofInterest for this
y_max = min(Ly_orb.JacobiConstant(indexOfInterest));
width = x_max-x_min;
height = y_max-y_min;
ROI_Position = [x_min y_min width height];
if you can select your axes. rectangle can get axes as input.

Más respuestas (0)


Más información sobre Visual Exploration en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by