Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB: Changing the line properties of a loaded figure?

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.

like image 773
aarelovich Avatar asked Feb 17 '12 14:02

aarelovich


People also ask

How do I change the properties of a figure in MATLAB?

Typing Ctrl+C when a modal figure has focus causes that figure to revert to a 'normal' WindowStyle property setting. This allows the user to type at the command line. Figures with the WindowStyle property set to 'modal' and the Visible property set to 'off' do not behave modally until MATLAB makes them visible.

How do I edit a figure in MATLAB?

Choose the Edit Plot option on the figure window Tools menu. Click on the selection button in the figure window toolbar. Choose an option from the Edit or Insert menu. For example, if you choose the Axes Properties option on the Edit menu, MATLAB activates plot edit mode and the axes appear selected.

How do I increase the width of a line in MATLAB?

set(graph1,'LineWidth',2); fplot(x1,[0,2],'k');


1 Answers

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','*') 
like image 128
yuk Avatar answered Sep 28 '22 22:09

yuk