MATLAB MATLAB 'LineOrder' and 'ColorOrder' help

  • Thread starter Thread starter end3r7
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
To set the color and line order for graphs in a program, the correct approach involves modifying the 'NextPlot' property. The suggested code is: set(gca, 'ColorOrder', [0 0 1; 0 1 0; 1 0 0], 'LineStyleOrder', {'-*', ':', 'o'}, 'NextPlot', 'ReplaceChildren'). This ensures that the specified colors and line styles cycle properly without altering the default settings for future runs. Additionally, it is noted that using 0 instead of gca may change global settings, although this has not been tested.
end3r7
Messages
168
Reaction score
0
For the life of me, I can't figure out how to set the color order and line order to cycle through the graphs of my program.

What I have right now (and I've tried a bunch of different stuff in the past) is

set(gca, 'ColorOrder', [0 0 1; 0 1 0; 1 0 0]);
set(gca,'LineStyleOrder',{'-*',':','o'});

as the first line of my code, but it wont' cycle,a nd I'm currently going insane (just a little).

Any help would be most apprecitaed.
 
Physics news on Phys.org
Please anyone? Also, if possible, I would like to not change the default order for future runs, since the program I'm writing will be used by tohers.
 
You need to change the nextplot settings
set(gca, 'ColorOrder', [0 0 1; 0 1 0; 1 0 0],'LineStyleOrder',{'-*',':','o'},'NextPlot','ReplaceChildren'),
you can change the global settings too, I think 0 instead of gca will do it, but I haven't tried

- J
 

Similar threads

Back
Top