Count the number of times I have plotted to a Figure
3 views (last 30 days)
Show older comments
Arthur Allen
on 1 Oct 2015
Answered: Walter Roberson
on 1 Oct 2015
I use
h = findobj('type','figure');
n_Fig = length(h)
to determine the number of open figures,
however, I want to know if I already have plotted to a specfic figure.Number
Plot_use_count = 0;
when I plot to figure.Number (what goes here???)
Plot_use_count = Plot_use_count +1
end
I use figure(Fig_Num) as way for the GUI user to define which figure to plot to.
then I use text
XLim = xlim; YLim = ylim;
X_range = XLim(2) - XLim(1);
Y_range = YLim(2) - YLim(1);
X_text = XLim(1) + 0.02.*X_range;
Y_text = YLim(1) + (0.1.*Y_range + 0.1.*Y_range.*Plot_use_count);
text(X_text,Y_text,Str_Variable)
to place text on the plot. This works fine for the 1st time Fig_Num is used, but if re-used (i.e. has the same value), the the text is overwritten, rather than
0 Comments
Accepted Answer
Walter Roberson
on 1 Oct 2015
current_count = get(Fig_num, 'UserData');
if isempty(current_count); current_count = 0; end
current_count = current_count + 1;
set(Fig_num, 'UserData', current_count);
0 Comments
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!