How can I put my plot behind the legend (GUI)

12 views (last 30 days)
Michel Hartung
Michel Hartung on 15 Aug 2018
Edited: jonas on 15 Aug 2018
Hello everyone,
I mad a matlab GUI with 3 axes. My first axe (handles.axes1) are filled with two figures (plotyy). But if I set my legend on it, the green line ofsecond figure (plot12) is over the legend. When I Change the legends colour to black, the Problem is still the same. The second figure from plotyy still is over the legend. Can anyone help me?
The code for the plot is the following:
[AX,H1,H2]=plotyy(handles.axes1,xwert,plot11,xwert,plot12);
grid(AX(1),'on');
l1=legend([H1;H2],'Lenkwinkel [°]', 'Fzg.-Geschw. [km/h]','Fahrpedal [%]', 'Fahrprogramm', 'Drehzahl [1000 U/min]');
It Looks like this (I dont want to see the green line in the legend):

Answers (1)

jonas
jonas on 15 Aug 2018
Edited: jonas on 15 Aug 2018
if h is the handle to your legend, i.e.
h=legend('location','northeast')
then change the backgroundcolor by:
set(h,'color','none') %transparent
set(h,'color','w') %white
I think white is default so I don't understand how you end up with your plot?
  6 Comments
Michel Hartung
Michel Hartung on 15 Aug 2018
Thanks a lot, but it isnt still working... I have really no idea, what it could be...
jonas
jonas on 15 Aug 2018
Edited: jonas on 15 Aug 2018
I'm not able to reproduce this issue at all. Could you send me an mat-file/m-file where you have this issue?
There is obviously something wrong with the legend. Only 3 out of 5 lines are associated with the legend, as you can see next to their handles where the string is missing in two cases. I would guess that also the purple line would appear in front of the legend, would they intersect.
5×1 graphics array:
Line
Line
Line (Fahrpedal [%])
Line (Fzg.-Geschw. [km/h])
Line (Lenkwinkel [°])
When you create the legend, try throwing all line handles in as input, in this way:
legend([h1 h2 h3 h4 h5],'string1','string2'...)
where h1...h5 are line handles that you create when you use plot

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!