Borrar filtros
Borrar filtros

colorbar for figure in panel created by GUI Layout Toolbox

5 visualizaciones (últimos 30 días)
I'm using the GUI Layout Toolbox (which is great!) to create a GUI. The GUI includes a BoxPanel in which I have placed a scatter plot with size and colours varying according to a third variable.
gui.ViewAxes = axes( 'Parent', gui.ViewPanel );
ax=gui.ViewAxes;
scatter(ax,x,y,zsize,zcolour,'filled')
(ViewPanel is a uiextras.BoxPanel) This works fine. But when I try to use the colorbar function:
cbar_handle=colorbar('peer',ax,'location','EastOutside');
not only does it not show any colorbar, the scatter plot itself vanishes and I am left with a blank panel.
Any way of getting the colorbar function to work in this context (I've used it for this type of chart in a simple figure without problems). Or is there another way of doing a colorbar without using the colorbar function?

Respuesta aceptada

Peter
Peter el 5 de Feb. de 2013
MATLAB creates the colorbar as a separate set of axes. This doesn't work correctly when the orignal axes are placed directly in a BoxPanel (or a CardPanel, or, as far as I know, any of the GUI Laytout Toolbox panel types). The fix for this is to first place a uicontainer within the desired panel and then place the axes within this uicontainer, like this:
c = uicontainer('Parent',gui.ViewPanel);
gui.ViewAxes = axes( 'Parent', c );
ax=gui.ViewAxes;
scatter(ax,x,y,zsize,zcolour,'filled');
cbar_handle=colorbar('peer',ax,'location','EastOutside');
Now MATLAB will automatically add the colorbar axes correctly.
This solution is from David Simpson's comment on the GUI Layout Toolbox file exchange page: http://www.mathworks.com/matlabcentral/fileexchange/authors/34325
  1 comentario
Kjeld Jensen
Kjeld Jensen el 6 de Feb. de 2013
Thanks. This was also the answer I got when I subsequently contacted Matlab support directly and it does indeed work perfectly.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by