setting graph defaults
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (5)
Wayne King
le 15 Nov 2011
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 commentaires
Jan
le 17 Nov 2011
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 commentaires
Daniel Shub
le 17 Nov 2011
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 commentaires
easily confused
le 18 Nov 2011
2 commentaires
Walter Roberson
le 18 Nov 2011
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
le 18 Nov 2011
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])
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!