Storing plots as a variable in a for loop
7 ビュー (過去 30 日間)
古いコメントを表示
The context to this code is; it is plotting 3 graphs and the data from these graphs need to be combined onto a four graph. So whilst I am processing the data for the first three graphs, I want to plot the relevant graph section for the fourth graph and store it in an array so that I can then call it for the fourth graph and its the legend without having to cycle through the data again.
r_col=[5,8,11]
h_col=[6,9,12]
size=[18,21,25]
xD=[2,6,10]
for z=1:3
clf
hold on
grid on
r=data(1:size(z),r_col(z))
h=data(1:size(z),h_col(z))
v=4*sqrt(h*sin(alpha))
A(z)=plot(5*v+xD(z)*D,r);
plot(r,v)
scatter(r,v)
name=[int2str(xD(z)),'D Velocity Profile']
xlabel('Distance from centre line (mm) ');
ylabel('Velocity of jet (m/s)');
print(name,'-dpng','-r300');
end
and then later on when I am doing the legend for the fourth graph, I would like to call it like so:
%applies axis labels
legend([L1,A(1),A(2),A(3),L6,L8,L9],'Core','2D velocities','6D velocities','10D velocities','Nozzle and Origin','Centre Line','Divergence Lines','FontSize',6,'Location','northwest')
So the key issue here is how to store plots so they can be used later?
8 件のコメント
Tommy
2020 年 4 月 15 日
Note that the Visible property is not the same as the HandleVisibility property. clf and findobj care about the latter, not the former:
>> a = axes;
>> clf
>> a
a =
handle to deleted Axes
versus
>> a = axes;
>> a.HandleVisibility = 'off';
>> clf
>> a
a =
Axes with properties:
XLim: [0 1]
YLim: [0 1]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
Show all properties
and
>> A = plot(1:10, 'HandleVisibility', 'off');
>> findobj('type','line')
ans =
0×0 empty GraphicsPlaceholder array.
>> A.HandleVisibility = 'on';
>> findobj('type','line')
ans =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1 2 3 4 5 6 7 8 9 10]
YData: [1 2 3 4 5 6 7 8 9 10]
ZData: [1×0 double]
Show all properties
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!