6
votes

I'm using MATLAB to plot some data. I would like to create the legend so that it divides information into two types, say Type1 and Type2. Each type of data has several specific lines of data which i am plotting. Suppose that:

  • Type1 data has line1 and line2
  • Type2 data has line1 and line2 and line3

This would make a 5 line plot. Now for the legend i can do something like:

legend('Type1: line1','Type1: line2','Type2: line1', ...
       'Type2: line2','Type2: line3');

But that repeats the 'Types' and the best way would be something that would look like:

(final legend output)

  • Type1:
    • line1
    • line2
  • Type2:
    • line1
    • line2
    • line3

Thanks a lot. Hope you can help with my first question here :D

1

1 Answers

2
votes

You may want to have a look at LEGENDFLEX that you can download from the Matlab File Exchange