[Waterloo] Draggable Line?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm finding the Waterloo package very useful to enhance Matlab plots. However, I'm still wrapping my head around how to work directly with some of the Java objects. (Clearly, I'm not a Java programmer!)
For example, I have a very simple GXGraph() plot:
% Generate some fake data
x = linspace(-10, 10, 100); % X Data
y = sin(x./10 .* 2 .* pi); % Y Data
% Plot the Data
gfig = GXFigure(); % Waterloo figure handle
gr1 = subplot(gfig, 1, 1, 1); % Create Graph 1 (gr1)
data1 = scatter(gr1, x, y); % Plot a scatter graph
(Of course, the above example only works after Waterloo has been added to MATLAB's path, and the initial 'waterloo.m' script has been run.)
Now, I'd like to add a line to my graph. I can do this:
% Add a line
annotation(gr1, 'line', [5, 5], [-1, 1]); % Add Line
gr1.getObject().repaint(); % Update Graph
...But I don't know how to:
(1) allow the user to move the line
(2) add a callback to notify me when the line is moving
Ultimately, I'm trying to get something much like Matlab's native imrect() function -- I want to define a resizeable region on my GXGraph.
Any suggestions?
댓글 수: 0
채택된 답변
Image Analyst
2012년 12월 11일
I don't think that will work. annotation works on the whole figure unfortunately, not on the units of the axes control itself like you'd want. There was a discussion of this within the past two weeks. You can create draggable lines with imdistline() or improfile(), both in the Image Processing Toolbox.
댓글 수: 3
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!