setting graph defaults
조회 수: 5 (최근 30일)
이전 댓글 표시
How do I set the default for all my graphs to be, for example, colorbar visible and interpreter none. I would like to set defaults once, rather than setting the properties in each graph. I've tried all sorts of incantations with DefaultColorbar, but I can't seem to get the right combination.
댓글 수: 0
답변 (5개)
Wayne King
2011년 11월 15일
Search for "Setting Default Property Values" in the MATLAB User's Guide. You can set default figure properties with set(0,...)
set(0,'defaultfiguretoolbar','none')
You can put options in a startup.m file, which is called by matlabrc.m
댓글 수: 0
Jan
2011년 11월 17일
You can set the DefaultFigureCreateFcn to a function, which sets the Colorbar:
set(0, 'defaultfigurecreatefcn', @myFigureCreateFcn)
But I'd prefer a dedicated function, which wraps the call to FIGURE:
function FigH = myFigure(varargin)
FigH = figure(varargin{:});
colorbar;
댓글 수: 0
Daniel Shub
2011년 11월 17일
Setting default behavior so that a "figure" always has a color bar is extremely problematic. Color bars are tied to an axis and not a figure. You might be able to build on Jan's answer and set the DefaultAxesCreateFcn, but this function is going to have to be complicated since the color bar is an axis and therefore is created with the function defined by DefaultAxesCreateFcn. It is unclear if you can determine what the nature of an axis is going to be before it is created so you would probably have to prevent recursive calls to your axes creator function.
Building your own function is also hard since there are so many ways a axis can be created.
댓글 수: 0
easily confused
2011년 11월 18일
댓글 수: 2
Walter Roberson
2011년 11월 18일
colorbar() creates a new axes of the figure, and draws a image within that new axes. The color image is thus tied to an axes of its own, but is not tied to the axes that the colorbar was drawn for.
Daniel Shub
2011년 11월 18일
While the colorbar seems like an axes, it is special ...
hfig = figure;
hax = axes;
hcb = colorbar;
ishandle([hfig, hax, hcb])
The issue is that
get([hax, hcb])
gives a weird error about hax and hcb having different classes. This is surprising since they both are of type axes. It is not to surprising that you get an error since hcb has some properties that hax doesn't. It is unclear though how to tell if an object of with a type axes is a colorbar or a regular axis.
You can see that hcb is linked to hax by deleting hax ...
delete(hax)
ishandle([hfig, hax, hcb])
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!