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

32 vues (au cours des 30 derniers jours)
Adam Goldsmith
Adam Goldsmith le 26 Mar 2017
Modifié(e) : dpb le 28 Mar 2017
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 commentaire
Nicholas Tarasenko
Nicholas Tarasenko le 28 Mar 2017
Modifié(e) : Nicholas Tarasenko le 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');

Connectez-vous pour commenter.

Réponses (1)

dpb
dpb le 26 Mar 2017
Modifié(e) : dpb le 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 commentaires
Jan
Jan le 27 Mar 2017
Modifié(e) : Jan le 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 le 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by