what does defaultAreaFaceColor do?

조회 수: 3 (최근 30일)
dave grundy
dave grundy 2021년 3월 30일
답변: AKennedy 2024년 5월 9일
at startup, if i execute:
set(groot,'defaultAreaFaceColor',[0.8 0.5 0.8]);
set(groot,'defaultAreaEdgeColor',[0.8 0.5 0.8]);
hF=figure;
arH1=area([1 2],[4 4],3) % blue (the first color in the matlab default list) box,
% with a purple border
% arH1 =
% Area with properties:
%
% FaceColor: [0 0.447 0.741]
% EdgeColor: [0.8 0.5 0.8]
% LineStyle: '-'
% LineWidth: 0.5
% BaseValue: 3
% XData: [1 2]
% YData: [4 4]
get(groot,'default') % struct with fields:
%
% defaultFigurePosition: [680 558 560 420]
% defaultFigurePaperPositionMode: 'auto'
% defaultFigureVisible: on
% defaultFigureToolBar: 'auto'
% defaultFigureMenuBar: 'figure'
% defaultAreaFaceColor: [0.8 0.5 0.8]
% defaultAreaEdgeColor: [0.8 0.5 0.8]
a blue box with a purple border is created (see the comments in the code above for the properties of the area)
but the "defaults" do appear to be set.
i have a feeling set(groot,'defaultFooBar') does not work the way that i think it does. i thought the defaults could be changed to the users preference with set(groot,'defaultFooBar') so that any subsequent figure would use those set defaults. however, i find that some work, some do not but i cannot determine what the difference is.
thanks in advance

답변 (1개)

AKennedy
AKennedy 2024년 5월 9일
Hi Dave,
MATLAB sets object properties in a specific order:
  1. Object-specific: Highest priority, set using "set(objectHandle,...)".
  2. Figure-level defaults: Defined using "set(groot,...)".
  3. MATLAB defaults: Built-in defaults used if neither 1 nor 2 are set.
The "area" object likely has pre-defined default colors that override your figure-level settings. You can try to
1. Set Object Properties Explicitly:
set(arH1, 'FaceColor', ..., 'EdgeColor', ...)
2. Create a Custom Area Function: This function replicates area but sets your preferred colors.
While setting figure-level defaults seems convenient, it can be overridden by object-specific properties. Directly modify the object or use custom functions for better control.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by