Insert a colorbar on a GUI?

8 vues (au cours des 30 derniers jours)
Nathan
Nathan le 4 Août 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

Réponses (1)

Paulo Silva
Paulo Silva le 4 Août 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

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by