Problems with legend in R2016b

조회 수: 1 (최근 30일)
Sebastien AMIOT
Sebastien AMIOT 2017년 3월 27일
댓글: Thomas Riedler 2024년 10월 3일
Why can I no longer add a plot with a legend in R2016b same way it used to be in previews versions?
During the migration to R2016b or R2017a, the script show some problems with legend function in the plot.
An example is a simple line after a plot: legend('Curve1','Curve2',1);
While it used to work fine prior to R2016b, we see the following response :
Error using legend>process_inputs (line 582) Invalid argument. Type 'help legend' for more information.
Error in legend>make_legend (line 340) [autoupdate,orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); %#ok
Error in legend (line 294) make_legend(ha,args(arg:end),version);
Error in Script_plot (line 274) legend('Curve1','Curve2',1);

답변 (3개)

Star Strider
Star Strider 2017년 3월 27일
The numeric location designations have been deprecated. Use the 'Location' name-value pair instead:
legend('Curve1','Curve2', 'Location','NE')
  댓글 수: 6
DGM
DGM 2024년 10월 2일
편집: DGM 2024년 10월 2일
In the versions that are old enough:
% 0 = 'Best'
% 1 = 'NorthEast'
% 2 = 'NorthWest'
% 3 = 'SouthWest'
% 4 = 'SouthEast'
% -1 = 'NorthEastOutside'
These were deprecated in R2013b, and were removed before R2015b
Thomas Riedler
Thomas Riedler 2024년 10월 3일
Thank you, that's what I was searching for!

댓글을 달려면 로그인하십시오.


Kim Hans
Kim Hans 2017년 6월 3일
I have the same problem with matlab 2017a. So can help me ?
  댓글 수: 1
Steven Lord
Steven Lord 2017년 6월 3일
See Star Strider's answer.

댓글을 달려면 로그인하십시오.


Sebastien AMIOT
Sebastien AMIOT 2017년 6월 6일
Hello,
The problem is not really how to add a legend anymore. We can read it thru Strider's answer, thanks, but also on the help. The question is more how to make sure our older Script to work on R2017a without changing each of the legend lines.
Thanks in advance,
  댓글 수: 2
Star Strider
Star Strider 2017년 6월 6일
You have to go back and manually change all the legend calls in your old code.
Walter Roberson
Walter Roberson 2017년 6월 7일
Write your own legend.m function that you put higher in the priority and which detects the use of the old style calls and converts the arguments and calls the built-in legend

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by