MATLAB: Changing the line properties of a loaded figure?

aarelovich picture aarelovich · Feb 17, 2012 · Viewed 32.8k times · Source

I've got a very simple question, for MATLAB users:

If I load a figure file (.fig) with the load command, is there any way to change the plotted lines properties from the command line? (width, color, marker, etc.)

PD: The first two options according to the information in Defining the Color of Lines for Plotting On this page… only work if you use the plot command. Apparently they are useless if you load the figure.

Answer

yuk picture yuk · Feb 17, 2012

You can get handles for all line objects on current figure with FINDOBJ function:

hline = findobj(gcf, 'type', 'line');

Then you can change some property for all the line objects:

set(hline,'LineWidth',3)

or just for some of them :

set(hline(1),'LineWidth',3) 
set(hline(2:3),'LineStyle',':') 
idx = [4 5];
set(hline(idx),'Marker','*')