MATLAB 'LineOrder' and 'ColorOrder' help

  • Context: MATLAB 
  • Thread starter Thread starter end3r7
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on configuring the 'ColorOrder' and 'LineStyleOrder' properties in MATLAB to cycle through graph styles. The user initially attempted to set these properties using set(gca, 'ColorOrder', [0 0 1; 0 1 0; 1 0 0]); and set(gca,'LineStyleOrder',{'-*',':','o'});, but faced issues with cycling. The solution provided involves using set(gca, 'ColorOrder', [0 0 1; 0 1 0; 1 0 0],'LineStyleOrder',{'-*',':','o'},'NextPlot','ReplaceChildren'); to ensure the settings apply correctly without altering the default for future runs.

PREREQUISITES
  • Familiarity with MATLAB graphics properties
  • Understanding of the gca function in MATLAB
  • Knowledge of color and line style specifications in MATLAB
  • Basic programming skills in MATLAB
NEXT STEPS
  • Explore MATLAB documentation on gca and its properties
  • Learn about customizing plots in MATLAB using set commands
  • Investigate global settings for color and line styles in MATLAB
  • Practice creating multiple plots with different styles in MATLAB
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and researchers who need to customize graph styles for better visualization in their projects.

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

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
4K
Replies
5
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
9K