How to update Axes LineStyle Order in Matlab Gui
显示 更早的评论
Dear Community,
I want to change the Linestyle of a Matlab Figure in a Gui. I have a popupmenu with a switch case structure where I can set the property. However, no change occurs whatsoever. I tried whats in commentary with refresdata and so forth, but no change. Do I need to replot all the data with plot (yet I dont know at all times which data I have. Or is there another way for it to update the figure?
Thanks a lot, below the code Ravi
switch get(hObject,'Value')
case 1
set(handles.axes_eis,'LineStyleOrder', '-');
guidata(hObject, handles);
% refreshdata(handles.axes_eis)
% refreshdata(handles.axes_eis,'caller')
% draw now
case 2
set(handles.axes_eis,'LineStyleOrder', '.-');
guidata(hObject, handles);
end
guidata(hObject, handles);
采纳的回答
更多回答(1 个)
Geoff Hayes
2015-10-17
Ravi - is the LineStyleOrder of the axes that you wish to change or the LineStyle of the curve plotted within the axes? I think that it may be the latter that you wish to change. If that is the case, then you will need to do something like the following in your popup menu callback
switch get(hObject,'Value')
case 1
set(handles.hPlot,'LineStyle', '-');
case 2
set(handles.hPlot,'LineStyle', '.-');
end
where handles.hPlot is the handle to the graphics object that was plotted using (for example) plot. The initialization of this field within handles may have occurred elsewhere in your code as
handles.hPlot = plot(...);
guidata(hObject,handles);
The first line is just the call to plot some data with the handle to the graphics object set in the hPlot field of handles. We then save this change to the updated handles object using guidata.
2 个评论
Ravi Goyal
2015-10-22
编辑:Ravi Goyal
2015-10-22
Geoff Hayes
2015-10-22
Ravi - you shouldn't create a function named plot since that conflicts with the built-in MATLAB function of the same name. What happens at the line of code
handles.hplot = plot(...);
Is plot the MATLAB function or yours? Please rename your function to something else and try again.
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!