how can I change the current axes in a GUI?

300 vues (au cours des 30 derniers jours)
Volker
Volker le 2 Fév 2011
Commenté : Rik le 13 Juin 2022
Hi, how can I change the current axes in a GUI? I try to use the line function, but I don’t know how to activate the right axes for plotting in the wanted figure. I guess, there should be a simple solution, but I can’t find.
Greetings
Volker
  3 commentaires
Qingyu
Qingyu le 14 Mai 2019
WCJHunter's answer works great! Thank you!
Rik
Rik le 13 Juin 2022
Comment posted as flag by Xb wang:
This ansewer is very useful.I spend servral days to find tha ways.Tank you !

Connectez-vous pour commenter.

Réponse acceptée

Paulo Silva
Paulo Silva le 2 Fév 2011
Here's one example:
axes(handles.axes2); %set the current axes to axes2
axes(h) makes existing axes h the current axes and brings the figure containing it into focus. It also makes h the first axes listed in the figure's Children property and sets the figure's CurrentAxes property to h. The current axes is the target for functions that draw image, line, patch, rectangle, surface, and text graphics objects.
  8 commentaires
Ryan
Ryan le 23 Août 2014
Thanks Peters, the setting in GUIDE were my issue
Corne van Zyl
Corne van Zyl le 22 Avr 2019
Thank you for this!

Connectez-vous pour commenter.

Plus de réponses (4)

thomeou
thomeou le 20 Juin 2013
Thanks for the post I wasted one and a half day with this same problem

Chris Rorden
Chris Rorden le 22 Juil 2013
Thanks, I also wasted a lot of time on this.

Itziar Uzqueda
Itziar Uzqueda le 23 Fév 2017
Hi! My problem is that when I try to plot an animatedline into axis1, instead of plotting there, another window is opened. also, when I try to use axes(handles.axes1) it says:
ans =
handle to deleted Axes
Mi code is here:
function Medir_Callback(hObject, eventdata, handles)
s = abrir_puerto();
handles.x=1:20;
handles.h=animatedline('Marker','o','LineWidth',1,'Color','k');
for i=1:(length(handles.x))
handles.distancia(i)=fscanf(s,'%d');
addpoints(handles.h,i,handles.distancia(i));
drawnow;
end
cerrrar_puerto(s);
I want it to be plotted in my Matlab GUI.
Thanks, Itziar
  2 commentaires
Adam
Adam le 23 Fév 2017
You should start a new question rather than post this as an answer.
You aren't specifying any axes though.
doc animatedline
In common with most plotting functions this includes a syntax that allows you to specify the axes handle as the first argument. Use it!
Itziar Uzqueda
Itziar Uzqueda le 23 Fév 2017
oh, sorry i didn't notice, i'm new in this kind of matters.
The probelm is that if i specify axes in animatedlines like this it comes to the error below.
handles.h=animatedline('Marker','o','LineWidth',1,'Color','k','Parent', handles.axes1);
Error using animatedline While setting property 'Parent' of class 'AnimatedLine': Cannot set property to a deleted object

Connectez-vous pour commenter.


nadji hadroug
nadji hadroug le 19 Fév 2018
You can see this example : x = 1000*rand(40,1); y = rand(40,1); scatter(x,y) xtickangle(45) ytickangle(90)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by