Problem with legends for multiple entries

1 view (last 30 days)
Hello everyone, I am plotting different entities on the figure window. The problem is when i use the legend function, it doesn't work and give me an error. All the plot function works fine as shown in the figure. The way i am doing it is like this,
[axuser,ayuser]=userdistribution();
figure(1);
hold on;
h(1)=plot(axuser,ayuser,'yo','MarkerSize',3,'MarkerFaceColor',[0.5,0.5,0.5],'DisplayName','Users');
%Layout the ABSs in the coverage area using square topology
[absx,absy]=abslayout();
h(2)=plot(absx,absy,'rh','MarkerSize',10,'MarkerFaceColor',[1,0,0],'DisplayName','ABSs');
%Layout the CABSs in the coverage area.
[cabsx,cabsy]=cabslayout();
h(3)=plot(cabsx,cabsy,'k*','MarkerSize',10,'MarkerFaceColor',[0,0,1],'DisplayName','RBSs');
%Layout the HBSs in the coverage area.
[hbsx,hbsy]=hbslayout();
h(4)=plot(hbsx,hbsy,'b^','MarkerSize',12,'MarkerFaceColor',[0.2,0.2,1],'DisplayName','HBSs');
legend(h);

Accepted Answer

José-Luis
José-Luis on 28 Jun 2016
legend(h(4),{'your legend'})
  3 Comments
José-Luis
José-Luis on 28 Jun 2016
Edited: José-Luis on 28 Jun 2016
legend(h(4),{'some legend'})
etc...
Perhaps you meant instead:
legend(h(1),{'first group', 'second group', 'third group'})
Please read the legend() documentation.

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!