acting on multiple plots across multiple axes
1 回表示 (過去 30 日間)
古いコメントを表示
This question might be summed up as: can I create an array or vector where each cell is a plot? but there is almost certainly a better way to do this, so the entirety is below.
I currently have files x1.txt, y1.txt, x2.txt, ... which are only numbers and contain the x and y values of some from different data sets (set 1, set 2, ...) and am plotting them on multiple axes. I have a function that looks like the below:
j=1;
while j <= 14
axes('Position',[.06,.94-(j-1)*.065,.93,.04]);
xdata = load(['../matlabresults/x' num2str(j) '.txt']);
ydata = load(['../matlabresults/y' num2str(j) '.txt']);
bar(xdata, ydata)
end
Which does exactly what I want. I want to manipulate these bar graphs later though (to make them visible and invisible upon user control) but they are not saved to a handle. If I do something like:
mylocation = axes('Position',[.06,.94-(j-1)*.065,.93,.04]);
myplot = bar(xdata, ydata)
Then the handle is overwritten each time, whereas if I do something like:
mylocation{j} = axes('Position',[.06,.94-(j-1)*.065,.93,.04]);
myplot{j} = bar(xdata, ydata)
Matlab complains that I can't write those sort of data to an array. Any advice? Is there a natural handle that each of these plots will take?
Note: Using Matlab2011b on MacOSX Lion. Note also that the actual function involves plotting 10 graphs per axes, along with annotation, but I still only want to manipulate one plot at a time (on all the 14 axes) upon user input, and simplified here for space.
0 件のコメント
採用された回答
Fangjun Jiang
2011 年 10 月 7 日
The MATLAB complaint is probably caused by your your previous definition of mylocation and myplot. If you initialize them properly, you should not have any problem. mylocation can be declared as double array, instead of cell array.
mylocation=cell(14,1);
myplot=cell(14,1);
mylocation{1} = axes;
mylocation{2} = axes;
mylocation{3} = axes;
myplot{1}=bar(rand(10,5),'stacked');
myplot{2}=bar(rand(10,5),'stacked')
myplot{3}=bar(rand(10,5),'stacked')
その他の回答 (1 件)
Walter Roberson
2011 年 10 月 7 日
Beyond what Fangjun said:
mylocation{j} = axes('Position',[.06,.94-(j-1)*.065,.93,.04]);
myplot{j} = bar(mylocation{j},xdata, ydata);
That is, after you create the axes, you want to be sure that your new bar plot draws in that axes.
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!