Borrar filtros
Borrar filtros

setting graph defaults

7 visualizaciones (últimos 30 días)
easily confused
easily confused el 15 de Nov. de 2011
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.

Respuestas (5)

Wayne King
Wayne King el 15 de Nov. de 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

Jan
Jan el 17 de Nov. de 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;

easily confused
easily confused el 16 de Nov. de 2011
I understand what you say, but I can't get seem to use it to make the colorbar be on by default.
So, specifically, how can I get the colorbar to be on by default in multiple figures?

Daniel Shub
Daniel Shub el 17 de Nov. de 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.

easily confused
easily confused el 18 de Nov. de 2011
So the answer is that there is no "default" property with respect to the visibility of the colorbar. I think the colorbar is a graphics object in itself, just like an axes, not tied to an axes. At least it appears that way in the proerties editor. It's parent is the figure. I guess the only way is to create a figurecb function to include creation of a color bar, which is hardly worth the hassle.
  2 comentarios
Walter Roberson
Walter Roberson el 18 de Nov. de 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
Daniel Shub el 18 de Nov. de 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])

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by