Making legend entry with multiple markers side-by-side

6 views (last 30 days)
Hello,
I would like to plot several data, then make only one legend entry for all of them, with all the different markers appearing one next to another. Is this possible? Otherwise, how can I change the position of markers in a legend (so far I only managed to change the position of the text).
Thanks,
Menka

Answers (1)

José-Luis
José-Luis on 3 Jan 2013
Edited: José-Luis on 3 Jan 2013
  • Place the markers next to each other:
If you are talking about changing a property to make it happen then the answer is no. There is no way to make it happen automagically, afaik. Legends are axes, so you could create your custom legend, or look in the file exchange to see if someone has done it before.
  • Can I change the position of the markers in the legend:
Yes. I can think of two options. The first is to plot the objects in the order you want them to appear. The second is to rearrange them once you have plotted them. You could look at the function uistack(). Here is a quick example
figure(1)
plot(rand(10,1),'ko');
hold on
plot(rand(10,1),'rs');
legend('first','second');
figure(2)
h1 = plot(rand(10,1),'ko');
hold on
h2 = plot(rand(10,1),'rs');
uistack(h1,'top');
legend('first','second')

Community Treasure Hunt

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

Start Hunting!