How to update Axes LineStyle Order in Matlab Gui

4 次查看(过去 30 天)
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);

采纳的回答

Ravi Goyal
Ravi Goyal 2015-11-3
I figured it out. Seems I only need to set the marker of the children in the plot. The Code I used
% --- Executes on selection change in lines_or_points.
function lines_or_points_Callback(hObject, eventdata, handles)
all_child_handles_axes_eis=get(handles.axes_eis,'Children');
all_child_handles_axes_drt=get(handles.axes_drt,'Children');
switch get(handles.lines_or_points, 'Value');
case 1 %LINES
set(all_child_handles_axes_eis(1:end), 'Marker', 'none')
set(all_child_handles_axes_drt(1:end), 'Marker', 'none')
case 2 %POINTS
set(all_child_handles_axes_eis(1:end), 'Marker', '.')
set(all_child_handles_axes_drt(1:end), 'Marker', '.')
end

更多回答(1 个)

Geoff Hayes
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
Ravi Goyal 2015-10-22
编辑:Ravi Goyal 2015-10-22
Hi Geoff, thanks for getting back. Tried your suggestion, however ran into following problem:
Error using set
Bad property value found.
Object Name: line
Property Name: 'LineStyle'.
Error in FIT_GUI>lines_or_points_Callback (line 207)
set(handles.hPlot,'LineStyle', '.-');
I named my handle as you suggested (even tried it as hplot) Wonder, if guidata has sth to do with it. My plot happens in a function I only pass "handles"
function plot(handles)
...
handles.hplot=plot(...)
guidata(handles.tag_of_gui, handles)
end
Any Idea, what this might be caused by? Thanks a bunch! Ravi
Geoff Hayes
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by