Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

get Color/names of a subplot

조회 수: 1 (최근 30일)
Max Müller
Max Müller 2014년 8월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
A long time ago Azzi Abdelmalek (28 Jul 2014) showed me a way to get the x and y Values of any subplot.Now I need a way to get the "LineColor" and the "names" which I didnt use in this example. (Due to its an example)However, imgaine every PlotPoint has its own name. Can u pls help me ?
% -----Example----------------------
for k = 1:9
x = 1:10;
y = rand(1,1)*20 *x;
z = (rand(1,1)*10).^x;
subplot(3,3,k);
plot(x,z,'--r',x,y,'-b');
end
%------The code-----------------------
h=findobj('type','axes');
for k=1:9
f=get(h(k),'children');
xi{k}=get(f,'xdata')
yi{k}=get(f,'ydata')
end

답변 (1개)

Adam
Adam 2014년 8월 7일
You can replace 'xdata' and 'ydata' in that example with any lineseries property (assuming all children of your axes lineseries objects which they would be from a plot instruction). These include 'Color'.
Plots don't have a name though so I'm not sure what you would be looking for in that case. If you want to give them a name then you could store a cell array of strings that you populate in the same loop you create your plots then you can just index into that later on to retrieve the name you assigned to aplot.
  댓글 수: 3
Adam
Adam 2014년 8월 7일
Well assuming you have first put that array of names together then looping around the xdata/ydata you retrieve in your shown example will allow you to index into that array. If it is a nested for loop and your array is just a 1d array as you showed you will have to convert your 2d nested for loop values (one for plot, one for point in the given plot) to the correct 1d index, but that is simple enough.
Max Müller
Max Müller 2014년 8월 7일
i have 9 subplots and need st that gives me all Data form 1 subplot, which i chose by clicking on it.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by