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
1 件のコメント
John Lunzer
2012 年 9 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!