Pass Two Handles to the same plot/Using 'animated line' with multiple axes in GUI

13 views (last 30 days)
Hi, This is my first time posting a question because this database is so extensive that I always found already-posted-answers whenever I had a question. Anyway, I'm trying to generate two plots in the same GUI. I'm using 'animated line' to plot. I don't want to use 'plot'. My code looks like this:
However, the second addpoints command is also plotting in the first plot (handle-liquid_compartment_graph) which I'm guessing is happening because the second addpoint is only considering the handle h4 and not the one directing it to the particular axes. Can anyone please suggest what can I do to: 1. Either pass both the handles (the one for the axes and the other one for animated line)? 2. Or some other way to plot multiple animated lines in different axes in one GUI?
You'll save my life if you can come up with an answer. Thanks a lot in advance.

Accepted Answer

Nade Sritanyaratana
Nade Sritanyaratana on 21 May 2015
Hi Anik,
Have you tried setting the "Parent" property of "h1" and "h4" to the desired axes (assuming they have been both created when "animatedline" was called)?
h1=animatedline('Marker','o','LineWidth',1,'Color','k', 'Parent', handles.liquid_compartment_graph); h4=animatedline('Marker','o','LineWidth',1,'Color','k', 'Parent', handles.solid_compartment_graph);
My guess is that "h1" and "h4" were created when "handles.liquid_compartment_graph" was the current axes.
The documentation pages for "animatedline" and its properties further elaborate on this behavior:
Nade Sritanyaratana
Nade Sritanyaratana on 17 Jun 2015
Hi Anik, sorry for missing this earlier -- I don't log on often, and I suppose I do not get emails for notifications. In either case, I suppose that by this point you may have found the correct solution. Regardless, I think here, you did not specify which axes should be associated to your calls to "legend", "xlabel", and "ylabel", so all three of these calls get associated with the current axes (See: gca).
My suggestion is to specify the axes as the first argument for each of the functions. You can see this kind of specification is supported for all three functions:
Also, I see that you call "gca" a couple of times, but I wonder if that is really what you intended to do. "gca" specifies the current axes object (typically the one you had most recently created or clicked on). In this case, instead of "gca", you might want to call handles.solid_compartment_graph instead.
hLegend = legend(handles.solid_compartment_graph,'D_{10}','D_{50}','D_{90}','Location','NorthWest','FontName','Georgia','FontSize',14);
hXLabel = xlabel(handles.solid_compartment_graph,'Time (min)');
hYLabel = ylabel(handles.solid_compartment_graph,'D_{10}, D_{50}, D_{90} (\mu\it{m})');
set(handles.solid_compartment_graph,'FontName' , 'garamond' );
set([hLegend, handles.solid_compartment_graph],'FontSize',12);
set([hXLabel, hYLabel],'FontName', 'georgia','FontSize',16);
set(handles.solid_compartment_graph, 'Box','off','TickDir','out','TickLength',[.02 .02],'XMinorTick','on','YMinorTick','on','XColor',[.3 .3 .3],'YColor',[.3 .3 .3],'LineWidth' ,1)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!