Thread Subject: how to change the color of figure using command

Subject: how to change the color of figure using command

From: Arthur Zheng

Date: 26 Oct, 2009 00:21:02

Message: 1 of 2

Already got a figure fig01.fig containing 2 curves generated from someone else' code below.
a=[1:100];
b=[2:101];
plot(a);
hold on;
plot(b);

Notice I already got the above figure, how can I change the color and line style of curve 1 using command? thanks.

Subject: how to change the color of figure using command

From: Andrew Stevens

Date: 26 Oct, 2009 03:54:02

Message: 2 of 2

"Arthur Zheng" <hzheng7@gatech.edu> wrote in message <hc2q1e$j3p$1@fred.mathworks.com>...
> Already got a figure fig01.fig containing 2 curves generated from someone else' code below.
> a=[1:100];
> b=[2:101];
> plot(a);
> hold on;
> plot(b);
>
> Notice I already got the above figure, how can I change the color and line style of curve 1 using command? thanks.

Arthur,

Give this a shot (after opening the .fig file):

h=findobj(gca,'type','line');
set(h(1),'color','r')

If the figure is as simple as you state, you can also use the following:

h=get(gca,'children');
set(h(1),'color','r')

-Andrew

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
children Andrew Stevens 25 Oct, 2009 23:59:07
findobj Andrew Stevens 25 Oct, 2009 23:59:07
figure curve Arthur Zheng 25 Oct, 2009 20:24:05
rssFeed for this Thread

Contact us at files@mathworks.com