Insert a colorbar on a GUI?

5 views (last 30 days)
Nathan
Nathan on 4 Aug 2011
Hey all,
So I have a Matlab GUI with UI controls that takes user input and does stuff with it. However, I'm looking to add a colorbar on my GUI on the right side, where small bars will appear based on the user input to certain fields. But, there isn't any direct way with guide to do so. How might I go about this? Thanks in advance.
Nathanf

Answers (1)

Paulo Silva
Paulo Silva on 4 Aug 2011
first select the current axes, just in case you have more than one axes on your gui, you also must have the handle for it (h=axes)
axes(h) %select the current axes, the h holds the handle for it
colorbar %now the current axes got one colorbar next to it
The colorbar is also one axes although it doesn't appear to be one, if you want to draw something on it create the colorbar like this hc=colorbar.
axes(hc) %select the colorbar as current axes
now you can draw lines on it.
Simple example, not using one GUI but it's similar
spy
hc=colorbar;
axes(hc);
line(xlim,[50 50],'LineWidth',8,'Color',[1 1 1])
%notice the white line on the colorbar

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!