Pass Two Handles to the same plot/Using 'animated line' with multiple axes in GUI
8 次查看(过去 30 天)
显示 更早的评论
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:
h1=animatedline('Marker','o','LineWidth',1,'Color','k');
h4=animatedline('Marker','o','LineWidth',1,'Color','k');
............
axes(handles.liquid_compartment_graph);
addpoints(h1,t_liq,d10_liq);
drawnow
...........
axes(handles.solid_compartment_graph);
addpoints(h4,t_sol,d10_sol);
drawnow
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.
0 个评论
采纳的回答
Nade Sritanyaratana
2015-5-21
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: http://www.mathworks.com/help/matlab/ref/animatedline.html http://www.mathworks.com/help/matlab/ref/animatedline-properties.html#property_parent
2 个评论
Nade Sritanyaratana
2015-6-17
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). http://www.mathworks.com/help/matlab/ref/gca.html 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(hLegend,'box','off')
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)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!