Plot into existing Gui figure/axes
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Adam Danz
am 21 Nov. 2019
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
Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance 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!