Plot into existing Gui figure/axes
조회 수: 9 (최근 30일)
이전 댓글 표시
hello, i am new at matlab and need help at the following problem:
i created a gui axes and colleceted x and y coordinates from it.
now I want to plot a dot at (x,y) into the existing axes. Like a marker where i clicked.
thats my code right now:
% --- Outputs from this function are returned to the command line.
function varargout = feld6_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
title('sPiElFeLd');
global n % n input is in an other gui
set(gca,'XTick',(1:1:n));
set(gca,'YTick',(1:1:n));
xlim([0.5 n+0.5])
ylim([0.5 n+0.5])
% squares for field
for k= 0:1:n-1
for j=0:1:n-1
rectangle('Position', [k+0.5 j+0.5 1 1])
end
end
% Click positions
[x,y] = ginput(1);
x = int64(x); % x Click position
y = int64(y); % y Click position
댓글 수: 4
Adam Danz
2019년 11월 21일
The reason you got an error with solution 1 is because I totally made up the variable name "axisHandle". I could have named it "SantaClaus". That variable should be the axis handle to the axis you're plotting on. It needs to be replaced with your variable name. Here's an example.
ax = axes();
plot(ax, 0,0,'bo')
See the documentation for more info: plot(ax,___)
The second problem is probably because you're not holding the axis. Check out the docmentation: hold on
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!