Plot Button Callback: Labeling Resulting Plot Axes and Title

Good afternoon,
I am working on a project that requires a GUI to change gain values in a Simulink model, simulate the model with the values, store the results, and then plot the results. This GUI is similar to the f14ex provided on Matlab help.
With the plot button, I am able to produce the desired results plot from my model. However, it is a plain plot without labeled axes and title.
I am reading about axes handles and figure handles, but I am still having trouble getting the axes label and title to show. Is it because my handlevisibility is off?? Something so small is causing me great issues. Any help would be greatly appreciated. Below is the segment of code for my plot button callback.
% ------------------------------------------------------------ % Callback for the Plot push button % ------------------------------------------------------------ function PlotButton_Callback(hObject, eventdata, handles) % hObject handle to PlotButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Callback of the uicontrol handles.PlotButton. currentVal = get(handles.ResultsList,'Value');
% Get data to plot
legendStr = cell(length(currentVal),1);
plotColor = {'b','g','r','c','m','y','k'};
for ctVal = 1:length(currentVal);
PlotData{(ctVal*3)-2} = handles.ResultsData(currentVal(ctVal)).timeVector;
PlotData{(ctVal*3)-1} = handles.ResultsData(currentVal(ctVal)).outputVector;
numColor = ctVal - 7*( floor((ctVal-1)/7) );
PlotData{ctVal*3} = plotColor{numColor};
legendStr{ctVal} = [handles.ResultsData(currentVal(ctVal)).RunName,'; Tamb=', ...
num2str(handles.ResultsData(currentVal(ctVal)).TambValue),'; Velocity=', ...
num2str(handles.ResultsData(currentVal(ctVal)).VelocityValue),'; Load=', ...
num2str(handles.ResultsData(currentVal(ctVal)).LoadValue)];
end
% If necessary, create the plot figure and store in handles structure
if ~isfield(handles,'PlotFigure') || ~ishandle(handles.PlotFigure),
handles.PlotFigure = figure('Name','T660 Simulation Output','Visible','off',...
'NumberTitle','off','HandleVisibility','off','IntegerHandle','off');
handles.PlotAxes = axes('Parent',handles.PlotFigure);
guidata(hObject,handles)
end
% Plot data
pHandles = plot(PlotData{:},'Parent',handles.PlotAxes);
% Add a legend, and bring figure to the front
legend(pHandles(1:2:end),legendStr{:})
% Make the figure visible and bring it forward
figure(handles.PlotFigure)
%endfunction PlotButton_Callback

 Respuesta aceptada

The TITLE, XLABEL and YLABEL functions all take an axes as the first argument. So after you do the plotting, call the functions with the handle to the axes as the first argument.
title(handles.PlotAxes,'Myplot')
xlabel(handles.PlotAxes,'My X')
ylabel(handles.PlotAxes,'My Y')

1 comentario

Carlo
Carlo el 9 de Mzo. de 2011
thanks. I have another question about the plot button.
would a subplot be extra code under the push button callback button or would I have to create another funtion for the subplot?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Mzo. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by