MATLAB Answers

yyaxis legend within app

3 views (last 30 days)
Owen Gebler
Owen Gebler on 13 Feb 2017
Commented: Owen Gebler on 3 Aug 2017
Within an app, (created using the App Designer) is it possible to create a legend containing entries for all lines within an axes, despite the lines being plotted on different y axes using the yyaxis function? For example, the following code will result in only a single legend entry being created, despite there being two lines on the axes:
x = linspace(0,10);
y = sin(3*x);
z = sin(3*x).*exp(0.5*x);
yyaxis(app.UIAxes,'left')
app.plot1 = plot(app.UIAxes,x,y);
yyaxis(app.UIAxes,'right')
app.plot2 = plot(app.UIAxes,x,z);
legend(app.UIAxes,{'plot1' 'plot2'};

  0 Comments

Sign in to comment.

Answers (1)

Teaking
Teaking on 3 Aug 2017
It is not possible before 2016b

  1 Comment

Owen Gebler
Owen Gebler on 3 Aug 2017
This behaviour is from 2016b.

Sign in to comment.