Clear Filters
Clear Filters

How do I change the default axis color and axis label text to black?

50 views (last 30 days)
I want to set the default so that all figures generated henceforth will have black axes and black axis labels. As of now, MATLAB default outputs this really godawful, ugly grey color intead of black and I am really really frickin sick of having to correct this in Illustrator every time. I don't want to have to manually set these values to black every single time I write code for a figure, so how do I change the default?
Extensive googling on this issue has returned nothing useful on this front. Any help is appreciated.
  1 Comment
Nicholas Tarasenko
Nicholas Tarasenko on 28 Mar 2017
Edited: Nicholas Tarasenko on 28 Mar 2017
Adam, try including this line everytime you create a figure: set(gca,'Color','b') I know it's a bit clunky to have to include this text every time you plot something. It probably beats doing it manually "in illustrator every time". Also, I use this nugget: set(gcf,'color','w') to control my background color, I also found you can default this with the following command: set(0, 'DefaultFigureColor', 'white');

Sign in to comment.

Answers (1)

dpb
dpb on 26 Mar 2017
Edited: dpb on 28 Mar 2017
Read <DefaultPropertyValues> for the "how" where...
set(groot,{'DefaultAxesXColor','DefaultAxesYColor','DefaultAxesZColor'},{'k','k','k'})
uses slightly the cell array form and fixes my previous error of deleting the 'Factory' had pasted then failed to change to 'Default'--had thought was doing it w/ a replace text operation but didn't work and didn't proof work...
  6 Comments
Jan
Jan on 27 Mar 2017
Edited: Jan on 27 Mar 2017
In general:
get(groot, 'factory')
Looking for "Axes":
F = fieldnames(get(groot, 'factoryAxes'));
F(contains(F, 'Axes'))
@dpb: "set(groot,'XAxesColor','k')" misses a 'default'.
Steven Lord
Steven Lord on 28 Mar 2017
From the "Specify Default Values" section of the page to which dpb linked:
Define a default property value using a character vector with these three parts:
'default' ObjectType PropertyName
So from Jan's example set(groot, 'defaultAxesXColor', ... whenever you create an object of type axes that has the groot object as an ancestor after setting that property on groot, its that axes will have the value you specified for its XColor property. Since groot is an ancestor of all graphics objects, this will affect all new axes.
If instead you had run set(gcf, 'defaultAxesXColor', ... only new axes added to the figure that was gcf at that time would be affected; new axes added to other figures would not.

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!