Borrar filtros
Borrar filtros

what does defaultAreaFaceColor do?

2 visualizaciones (últimos 30 días)
dave grundy
dave grundy el 30 de Mzo. de 2021
Respondida: Abhinaya Kennedy el 9 de Mayo de 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

Respuestas (1)

Abhinaya Kennedy
Abhinaya Kennedy el 9 de Mayo de 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.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by