フィルターのクリア

what does defaultAreaFaceColor do?

2 ビュー (過去 30 日間)
dave grundy
dave grundy 2021 年 3 月 30 日
回答済み: Abhinaya Kennedy 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 件)

Abhinaya Kennedy
Abhinaya Kennedy 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 Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by