colorbar for figure in panel created by GUI Layout Toolbox
3 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Peter
2013-2-5
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
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!