Check if a plot exists on an already open MATLAB subplot
Question
I have a subplot in MATLAB that has already been created, its axes colors set, etc, and all ready. I then plot a histogram on it.
Now I come back to it, (within a loop), and I want to check is there is something already 'plotted' on that subplot, histogram or normal plot. If there was something there, do_something, otherwise, do_something_else.
How to I check the 'occupancy' of a subplot or plot in general?
Solution
You could check whether or not the subplot
has children
:
isempty(get(yourSubplotHandle, 'children'))
This statement is true
for empty subplots.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow