Change saved .fig figure with multiple axes and plots

1 vue (au cours des 30 derniers jours)
Bob Johnson
Bob Johnson le 2 Sep 2011
Hi, I want to change some properties of a .fig figure that I have saved.
With one set of axes on the figure and one line on the plot, I use the following script to change the LineStyle property:
h_fig = open([folderpath 'figurename.fig']);
h_axes = gca;
h_plot = get(h_axes,'Children');
set(h_plot,'LineStyle','-','LineWidth',3.0,'Color','black')
But, my question is how to do the same change on one set of axes if there are 4 sets of axes on one figure and 2 lines on that plot.
d = 0.06; % distance from edge
fh = figure(305);
ax1 = axes('position',[d 0.56 0.38 0.38])
h1 = plot(x,y)
h2 = plot(x,z)
ax2 = axes('position',[0.56 0.56 0.38 0.38])
h1 = plot(x,y)
h2 = plot(x,z)
ax5 = axes('position',[0.06 0.06 0.38 0.38])
h1 = plot(x,y)
h2 = plot(x,z)
ax4 = axes('position',[0.56 0.06 0.38 0.38])
h1 = plot(x,y)
h2 = plot(x,z)
So, I save this and I want to open it again and change only plot ax1 and change the line type for h2 to
set(h_plot,'LineStyle','-','LineWidth',3.0,'Color','black')
Thanks a lot for your help.
All the best, Bob

Réponses (1)

Grzegorz Knor
Grzegorz Knor le 2 Sep 2011
Try in this way:
lns = findobj('Type','Line');
for k=1:length(lns)
if 'condition for identifying'
set(h(k),'LineStyle','-','LineWidth',3.0,'Color','black')
end
end
Grzegorz

Catégories

En savoir plus sur Graphics Object Properties 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