what does defaultAreaFaceColor do?

1 view (last 30 days)
dave grundy
dave grundy on 30 Mar 2021
Answered: Abhinaya Kennedy on 9 May 2024
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

Answers (1)

Abhinaya Kennedy
Abhinaya Kennedy on 9 May 2024
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.

Categories

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

Community Treasure Hunt

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

Start Hunting!