setting graph defaults
3 次查看(过去 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!