get(0,'default') does not list all default properties
이전 댓글 표시
Here is my output in Matlab2012a for the following command:
>> get(0,'default')
ans =
defaultFigurePosition: [560 528 560 420]
defaultTextColor: [0 0 0]
defaultAxesXColor: [0 0 0]
defaultAxesYColor: [0 0 0]
defaultAxesZColor: [0 0 0]
defaultPatchFaceColor: [0 0 0]
defaultPatchEdgeColor: [0 0 0]
defaultLineColor: [0 0 0]
defaultFigureInvertHardcopy: 'on'
defaultFigureColor: [0.8000 0.8000 0.8000]
defaultAxesColor: [1 1 1]
defaultAxesColorOrder: [7x3 double]
defaultFigureColormap: [64x3 double]
defaultSurfaceEdgeColor: [0 0 0]
I know there are more default values than this as I can access them individually if I already know them (DefaultLineLineWidth, DefaultLineLineStyle, etc.) As far as I can tell this list should be massive. That command is the most common suggestion for listing default values.
Any suggestions on why it doesn't list all default values (related to figures/axes/plot/etc)? Thanks!
채택된 답변
추가 답변 (1개)
Here is a silly little function to get all of those defaults listed. You could modify this to produce more or less by manipulating the cell array HC, and of course instantiating an instance of any object in named in HC. Also, one could modify this to allow a handle to be passed in, then return the defaults for only that type of object.
function S = defaultprops()
% Returns default property values for common HG objects.
% Only returns those properties who have non-empty values.
% Author: Matt Fig
HC = {'figure','axes','line','text','patch','uicontrol',...
'uicontextmenu','uimenu','image','surface','light',...
'rectangle'};
warning off %#ok
onof = get(0,'showhidden');
set(0,'showhidden','on');
% Create the objects.
F = figure('visible','off','tag','propfig');
plot(1:10);
text;
uicontrol;
patch([0 0],[0 0],'r');
image;
rectangle;
surface;
uicontextmenu;
uimenu;
light;
for ii = 1:length(HC)
prp = get(findobj(F,'type',HC{ii}));
fn = fieldnames(prp);
for jj = 1:length(fn)
try
dfp = get(0,['default',HC{ii},fn{jj}]);
if ~isempty(dfp) % Remove to return all settables.
S.(HC{ii}).(fn{jj}) = dfp;
end
catch %#ok
end
end
end
close(F)
set(0,'showhidden',onof)
warning on %#ok
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!