get axis value of a subplot

46 vues (au cours des 30 derniers jours)
Max Müller
Max Müller le 28 Juil 2014
Commenté : Azzi Abdelmalek le 11 Août 2014
hey Guys
I ve created a program which creates 9 different subplots with 3 different plot lines. My Questions is: how can i get the x andy values of each subplot.
for example: One of the titles of my plot is simply A. Another is B. How can i get the values in an array which has the same name.
Thanks
  2 commentaires
Patrik Ek
Patrik Ek le 28 Juil 2014
Modifié(e) : Patrik Ek le 28 Juil 2014
I think that eval is the way to go then. However, if not absolutely necessary I recommend you to not go there, see alternatives ot eval. One problem is that eval is evaluated in runtime.
Azzi Abdelmalek
Azzi Abdelmalek le 11 Août 2014
Max , please don't add all these answers, if you want to add a comment , just under my answer or someone else's answer, click on comment on this answer

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 28 Juil 2014
Modifié(e) : Azzi Abdelmalek le 28 Juil 2014
% -----Example----------------------
x=repmat((1:10)',1,9);
y=rand(10,9);
for k=1:9
subplot(3,3,k);
plot(x(:,k),y(:,k));
end
%------The code-----------------------
h=findobj(gcf,'type','axes');
for k=1:9
f=get(h(k),'children');
xi{k}=get(f,'xdata');
yi{k}=get(f,'ydata');
end
outx=fliplr(cell2mat(xi')');
outy=fliplr(cell2mat(yi')');
%-------------test --------------------
isequal(x,outx)
isequal(y,outy)
  1 commentaire
Max Müller
Max Müller le 28 Juil 2014
works perfect...thanks

Connectez-vous pour commenter.

Plus de réponses (3)

Max Müller
Max Müller le 11 Août 2014
Hey Azzi,
hope u can help me one more time. ur code works perfect for every normal plot. But if i use it on my Plot, it shows me that my chosen Plot has 42 handles ??????? my Plot contains 41 points. I guess this has to mean sth. Can u pls tell me why my plot has 42 children-handles ?
  1 commentaire
Adam
Adam le 11 Août 2014
Sounds like you have plotted each point as its own individual line object

Connectez-vous pour commenter.


Max Müller
Max Müller le 11 Août 2014
Somehow this must be the case but actually i am ploting a few amount of Arrys into one axes. The x value is always the same and th y value keeps changing...maybe this is the reason... gona check it.
  1 commentaire
Max Müller
Max Müller le 11 Août 2014
Modifié(e) : Max Müller le 11 Août 2014
this code is the reason
text(theta,y,strcat({' '},names),'Interpreter','none','rotation',90)
theta = x / y = y / names = Name of the point
Is there an alternative for this code ?

Connectez-vous pour commenter.


Max Müller
Max Müller le 11 Août 2014
When every handle represents one Point. How can I reach its value.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by