MATLAB Answers

How to change the standard of coloring figures

34 views (last 30 days)
Tim Sønderby
Tim Sønderby on 3 Nov 2011
I would like to have matlab giving my plots in b balck and white and using different styles of dotted and dashed lines instead on the standard way of differing plots with color.
This would make it much easier when you export the figure for an article.
guess there must be a way to set this up in MATLAB.
thanks,

Answers (3)

Jan
Jan on 3 Nov 2011
figure('DefaultAxesColorOrder', [0 0 0; 0.4, 0.4, 0.4; 0.7, 0.7, 0.7], ...
'DefaultAxesLineStyleOrder', '-|:|.-');
plot(bsxfun(@plus, rand(100, 16), 1:16)); % Test data
I've omitted the '--' style, because it looks confusing sometimes.
You can set the color style as default for all new figures also:
set(0, 'DefaultAxesColorOrder', ...)
To reset it after creating the black and white diagrams:
set(0, 'DefaultAxesColorOrder', 'factory')
I prefer markers in BW diagrams with more than 4 different lines. For a line with 100 points it looks ugly when 100 markers appear. Therefore I've written a LineWithMarkers function, which adds only 10 markers per line. In addition The X-locations of the markers are shifted horizontally to reduce the overlap between the markers.
  1 Comment
Patrick Kalita
Patrick Kalita on 3 Nov 2011
And if you want these defaults to apply for all figures in every MATLAB session, you can add the set(0, 'Default.. calls to a startup.m file (http://www.mathworks.com/help/techdoc/ref/startup.html).

Sign in to comment.


Fangjun Jiang
Fangjun Jiang on 3 Nov 2011
Function plot() allows you to specify the line color, marker and line style. You'll just need to specify the color as black ('k') all the time. To set the background color as white, use set().
f=figure(1);
set(f,'color',[1 1 1]);
plot(magic(10),'k');
grid on;

Tim Sønderby
Tim Sønderby on 3 Nov 2011
But this only help half the problem as I still have to manually change all the line styles otherwise I cannot distinguish them from each other.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by