0

I have two problems that I'm trying to tackle at once.

I have a loop that plot on the same figure two cuvres of the same color at each iteration, one normal and one dashed.

I would want my legend to only have the normal lines (dashed curves are interpolated data, it means the same thing so there is no use for it to be in the legend). I can't use handles because I'm in a loop but I can't ignore legend entries because I don't have the handles.

If someone could provide me with a solution (without the use of handles if possible) that would be really great, thank you.

AdrienNK
  • 850
  • 8
  • 19
  • 1
    If this doesn't require too much overhead, you can change the plotting order so that all the full lines are plotted first and the dashed lines after them, so that you can give legend entries to the full curves only. This will probably require you to do two loops instead of one. – buzjwa May 29 '14 at 17:15
  • I had a version of my code where I did that but I changed it so it could be more readable and modulable and it added a lot of overhead for that specific part. This is my ultimate back up plan but I'd prefer to avoid it. – AdrienNK May 29 '14 at 17:18
  • 2
    I don't get what should be the problem with the handles? – Robert Seifert May 29 '14 at 17:58
  • I can't do h1 = plot inside my loop. I suppose I could try to work with a vector of handles but I don't really know how I would do that. By the way is there a way to create a legend only by telling the color and type of curve (unrelated to the datas of the plot) ? – AdrienNK May 29 '14 at 18:05
  • 1
    @AdrienNK: Exactly, you need to create a vector of handles. `h=[]` creates an empty vector and `h(end+1)=plot(...)` appends an element to the end. Try it, if you don't succeed please add your code to the question. Manually creating a legend is possible but much more complicated. – Daniel May 29 '14 at 18:23
  • 1
    That turned how to be less complicated that what I first assumed (I tought I would have to put a handle even for the dashed lines so I would have to skip some handles in the legend but it was not needed). Thank you very much. – AdrienNK May 29 '14 at 18:32

0 Answers0