Thread Subject: Reset the Color Order Property of an axis

Subject: Reset the Color Order Property of an axis

From: Camron Call

Date: 7 Aug, 2009 21:32:02

Message: 1 of 8

I saw this question on the Expert's Exchange and I want to know the answer without paying for it.

I was wondering does anyone know how to reset the color order and line style manually in matlab?
I know each time you call high-level functions like 'plot' and 'plot3' it resets them automatically (provided you didn't do a 'hold on' beforehand) but how do you do this manually?
I'm NOT trying to set a new color order or line style, I just want to reset them so that my next call to 'plot' starts at the beginning of the current color order and line style lists again and continues.

Thanks in advance.

Subject: Reset the Color Order Property of an axis

From: CTRAX

Date: 7 Aug, 2009 21:51:39

Message: 2 of 8

On Aug 7, 5:32 pm, "Camron Call" <camronc...@gmail.cam> wrote:
> I saw this question on the Expert's Exchange and I want to know the answer without paying for it.
>
> I was wondering does anyone know how to reset the color order and line style manually in matlab?
> I know each time you call high-level functions like 'plot' and 'plot3' it resets them automatically (provided you didn't do a 'hold on' beforehand) but how do you do this manually?
> I'm NOT trying to set a new color order or line style, I just want to reset them so that my next call to 'plot' starts at the beginning of the current color order and line style lists again and continues.
>
> Thanks in advance.

Yes, Expert's Exchange is a pile of shite.
Here's one way you can do this:

%store the originals
origCO=get(gcf,'DefaultAxesColorOrder');
origSO=get(gcf,'DefaultAxesLineStyleOrder');

%set them to something else:
set(gcf,'DefaultAxesColorOrder',[1 1 0;0 1 1;1 0 1],...
      'DefaultAxesLineStyleOrder',':|-|--')

%back to default
set(gcf,'DefaultAxesColorOrder',origCO,...
      'DefaultAxesLineStyleOrder','origSO)

%You can also set them on a global level. Try:
get(0,'DefaultAxesColorOrder')

Subject: Reset the Color Order Property of an axis

From: Camron Call

Date: 7 Aug, 2009 22:25:03

Message: 3 of 8

This doesn't seem to be working for me.

This loop plots the test data that is selected by the user. There may be any number of plots to be compared on the same axis:

% code
hold all;
            for j=1:length(testrow)
                plot(xaxis{j,:}',testdata{testrow(j),:}','LineWidth',lw)
            end

%/end code

testrow is a vector containing the selected rows from a list box.

Does the hold all; command make it so that the solution in the previous post does not work? Every time my plot button is pressed, the colors start off with the next in line and not with the regular blue.

Subject: Reset the Color Order Property of an axis

From: Camron Call

Date: 7 Aug, 2009 22:55:04

Message: 4 of 8

This doesn't seem to be working for me.

This loop plots the test data that is selected by the user. There may be any number of plots to be compared on the same axis:

% code
hold all;
            for j=1:length(testrow)
                plot(xaxis{j,:}',testdata{testrow(j),:}','LineWidth',lw)
            end

%/end code

testrow is a vector containing the selected rows from a list box.

Does the hold all; command make it so that the solution in the previous post does not work? Every time my plot button is pressed, the colors start off with the next in line and not with the regular blue.

Subject: Reset the Color Order Property of an axis

From: dpb

Date: 7 Aug, 2009 23:00:09

Message: 5 of 8

Camron Call wrote:
> This doesn't seem to be working for me.
>
> This loop plots the test data that is selected by the user. There
> may be any number of plots to be compared on the same axis:
>
> % code hold all; for j=1:length(testrow)
> plot(xaxis{j,:}',testdata{testrow(j),:}','LineWidth',lw) end
>
> %/end code
>
> testrow is a vector containing the selected rows from a list box.
>
> Does the hold all; command make it so that the solution in the
> previous post does not work? Every time my plot button is pressed,
> the colors start off with the next in line and not with the regular
> blue.

I suspect so --

I'd first try to reset the default order in the loop and see if it
starts over again; I'm thinking even that may not.

If not, you would probably have to keep up w/ the number of plots and
rearrange the order to make the position of the first default color that
position in the color vector.

AFAIK there's no property user-settable that lets you only reset the
internal index into the order array for color (or linestyle either, for
that matter).

Seems like another of the "so obvious but..." kinda' missing
details....I've noticed it before; unlike some others that come up from
time to time I don't recall this is one I ever formally submitted a
feature request for.

--

Subject: Reset the Color Order Property of an axis

From: Camron Call

Date: 7 Aug, 2009 23:33:01

Message: 6 of 8

I had thought of keeping track of the order like you mentioned. The more I think about it, it might not be to difficult. Thanks to all for helping.

Cam

Subject: Reset the Color Order Property of an axis

From: dpb

Date: 7 Aug, 2009 23:45:24

Message: 7 of 8

Camron Call wrote:
> I had thought of keeping track of the order like you mentioned. The
> more I think about it, it might not be to difficult. Thanks to all
> for helping.

Oh, I agree that it's not particularly hard at all; just one of those
pita details that seems as if shouldn't be necessary is all...

--

Subject: Reset the Color Order Property of an axis

From: Camron Call

Date: 8 Aug, 2009 01:18:01

Message: 8 of 8

 
> Oh, I agree that it's not particularly hard at all; just one of those
> pita details that seems as if shouldn't be necessary is all...
>

AMEN!!!

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
colororder Camron Call 7 Aug, 2009 17:34:03
reset Camron Call 7 Aug, 2009 17:34:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com