Problem with legends for multiple entries

1 visualizzazione (ultimi 30 giorni)
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);

Risposta accettata

José-Luis
José-Luis il 28 Giu 2016
legend(h(4),{'your legend'})
  3 Commenti
José-Luis
José-Luis il 28 Giu 2016
Modificato: José-Luis il 28 Giu 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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by