Problem using ginput to reposition axes
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marc Jakobi
el 30 de En. de 2016
Comentada: Marc Jakobi
el 1 de Feb. de 2016
Hi. I am working on a function that lets you interactively reposition an axes (for example a subplot) using the mouse input. This is my attempt (simplified a bit) for one axes
%create invisible axes covering the figure
drawax = axes('Position',[0, 0, 1, 1],'Visible','off');
[left, bottom] = ginput(1); %get position
[top, right] = ginput(1);
newpos = [left, bottom, max(0,right-left), max(0,top-bottom)];
ax1.Position = newpos; %ax1 is the subplot that is to be repositioned.
[left, bottom] return the correct positions, but [top, right] seem to be returning coordinates from ax1. Is there a way I can force ginput to select points that correspond with the normalized position of drawax?
2 comentarios
Geoff Hayes
el 31 de En. de 2016
Marc - please clarify what you mean by reposition an axes. Are you just trying to zoom in on a particular area and so are trying to reset the x and y axis limits?
Respuesta aceptada
Image Analyst
el 31 de En. de 2016
Perhaps call xlim() and ylim() to find out your "field of view" in your graph, then call ginput(1) to find a desired center of the graph, then, based on that, compute new limits for the displayed x and y ranges, then call xlim() and ylim() to assign them to the graph.
5 comentarios
Image Analyst
el 1 de Feb. de 2016
You can just accept this one. Thanks! Glad it worked out for you.
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects 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!