Borrar filtros
Borrar filtros

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

50 visualizaciones (últimos 30 días)
Adam Goldsmith
Adam Goldsmith el 26 de Mzo. de 2017
Editada: dpb el 28 de Mzo. de 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 comentario
Nicholas Tarasenko
Nicholas Tarasenko el 28 de Mzo. de 2017
Editada: Nicholas Tarasenko el 28 de Mzo. de 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');

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 26 de Mzo. de 2017
Editada: dpb el 28 de Mzo. de 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 comentarios
Jan
Jan el 27 de Mzo. de 2017
Editada: Jan el 27 de Mzo. de 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 el 28 de Mzo. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by