How to update Subplots in GUI
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi there,
I'm having trouble in generating a subplot for my GUI.
I essentially have a gui linked to a chickbox that creates a subplot based on which checkboxes are selected. However, I need to also rewrite what's in my GUI axis after each plot; this means that every time I plot my data, I need the axes in Guide I created to update as well. Before data was being plotted on the same types of plots meaning that (for example) height and weight were both the y axis and while I graphed height first then tried to plot weight, weight ended up using the same subplot configuration as the height plot and both were displayed as well.
0 Kommentare
Antworten (1)
Adam Danz
am 14 Dez. 2018
Bearbeitet: Adam Danz
am 14 Dez. 2018
Presumably your axes are created from within the GUI. Are you using GUIDE or are you building the GUI from scratch? In any case, when you create the axes, you need to store the axis handles. If you're using GUIDE, they are already stored in the list of handles. If you're building the GUI from scratch, you need to store the axis handles when you great the axes. For each checkbox callback function, you need to specify which axis it should alter. I can't really be more specific without knowing how you've created the GUI. If needed, I can add more detail in the comments below if you need more help with my solution.
2 Kommentare
Adam Danz
am 19 Dez. 2018
"I fixed my issue with changing graphs somehow..."
If you're unsure why your code works now you might want to invest some time understanding what was wrong and how you fixed it. You might find that the solution isnt' general or causes a different set of problems.
"I've used clf but it only clears the axes for the second graph despite choosing the axes object I placed in the GUI"
The clf command clears a figure, cla clears an axis. If you want to clear a specific axis you need to include the handle: cla(h) where h is the handle to the axis you want to clear.
It sounds like all of your problems can be solved by using axis handles as I mentioned in my solution.
For example:
figure;
axh = axes; %axh is the handle to my axes
plot(axh, rand(1,20))
%clear axes
cla(axh)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!