필터 지우기
필터 지우기

How to make line objects and be able to track / zoom into them?

조회 수: 1 (최근 30일)
Suki Sandhu
Suki Sandhu 2017년 1월 18일
답변: Walter Roberson 2017년 1월 18일
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.

채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 18일
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개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by