Filter löschen
Filter löschen

colorbar for figure in panel created by GUI Layout Toolbox

5 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Peter
Peter am 5 Feb. 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 Kommentar
Kjeld Jensen
Kjeld Jensen am 6 Feb. 2013
Thanks. This was also the answer I got when I subsequently contacted Matlab support directly and it does indeed work perfectly.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by