How to update Axes LineStyle Order in Matlab Gui

4 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Ravi Goyal
Ravi Goyal il 3 Nov 2015
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

Più risposte (1)

Geoff Hayes
Geoff Hayes il 17 Ott 2015
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 Commenti
Ravi Goyal
Ravi Goyal il 22 Ott 2015
Modificato: Ravi Goyal il 22 Ott 2015
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 il 22 Ott 2015
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.

Accedi per commentare.

Categorie

Scopri di più su Graphics Object Properties in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by