How to make line objects and be able to track / zoom into them?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suki Sandhu
am 18 Jan. 2017
Beantwortet: Walter Roberson
am 18 Jan. 2017
Working on this little program and I want it to be able to zoom into lines as shown in the following images:
The way I have managed to simulate that effect so far is to use XLim and YLim for the figures coordinates around the lines to make it appear as its been tracking the lines. The lines are just plotted over the image with a double for loop.
Is there a way of individually tracking lines and being able to individually view/zoom into them. Any help/advice is much appreciated. Its fun trying to figure this out I must admit but I must reach out for help now.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 18 Jan. 2017
At the time you create a line, you could give it a Callback property. You could probably use the same callback for all of the lines. The Callback would look something like,
function zoom_into_line(hObject, event)
line_x = get(hObject, 'XData');
line_y = get(hObject, 'YData');
min_x = min(line_x);
max_x = max(line_x);
min_y = min(line_y);
max_y = max(line_y);
zoom_x_min = min_x * .9;
zoom_x_max = max_x * 1.1;
zoom_y_min = min_y - 50; %you will need to adjust this line
zoom_y_max = max_y + 50; %you will need to adjust this line
ax = ancestor(hObject, 'axes');
set(ax, 'XLim', [zoom_x_min, zoom_x_max], 'YLim', [zoom_y_min, zoom_y_max]);
The idea here would be that when you click on the line, the callback runs and automatically zooms the axes to be centered on the x and y coordinates of the line.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Visual Exploration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!