필터 지우기
필터 지우기

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

조회 수: 50 (최근 30일)
Adam Goldsmith
Adam Goldsmith 2017년 3월 26일
편집: dpb 2017년 3월 28일
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
Nicholas Tarasenko
Nicholas Tarasenko 2017년 3월 28일
편집: Nicholas Tarasenko 2017년 3월 28일
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');

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2017년 3월 26일
편집: dpb 2017년 3월 28일
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
Jan
Jan 2017년 3월 27일
편집: Jan 2017년 3월 27일
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 2017년 3월 28일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by