Hi Guys,
I am making a GUI which, to all intents and purposes, plots some data. I wanted a set of radio buttons to change the plot colour. To make sure only one colour was selected I used a button group. When I ask to see the radio button call back I am told the uiButtonGroup (plotColour) is managing the call back. This is my button group SelectionChangeFcn code :
function plotColour_SelectionChangeFcn(hObject,eventdata) switch get(hObject,'Tag') % Get Tag of selected object.
case 'Blue' setappdata(handles.figure1,'Colour','blue') case 'Red' setappdata(handles.figure1,'Colour','red') case 'Green' setappdata(handles.figure1,'Colour','green') case 'Yellow' setappdata(handles.figure1,'Colour','yellow') case 'Black' setappdata(handles.figure1,'Colour','black') case 'cyan' setappdata(handles.figure1,'Colour','cyan') case 'Magenta' setappdata(handles.figure1,'Colour','magenta') otherwiseend
This is the section of code which plots the data:
global noFiles global plotLength dataStore = getappdata(handles.figure1 , 'dataStore'); f = getappdata(handles.figure1 , 'f'); plotColour_SelectionChangeFcn(hObject,eventdata) colour = getappdata(handles.figure1,'Colour'); hold on for i = 1:noFiles plot(f(2:plotLength),dataStore(2:plotLength,i),'color',colour) end hold off
Before this I initialise 'Colour' to blue with:
setappdata(handles.figure1,'Colour','blue')
The figure plots so I know it is executing the line :
plotColour_SelectionChangeFcn(hObject,eventdata)
But It doesn't seem to be updating the 'Colour' value. Its almost as if none of the tags in the switch/case loop are matching, but I don't know why. I have check and doubled checked the tags for the radio buttons in the property inspector.
Any help would be really appreciated, Thanks in advance 🙂
Tim
Best Answer