필터 지우기
필터 지우기

No legend when plotting fit object

조회 수: 36 (최근 30일)
Daniel
Daniel 2021년 2월 22일
편집: dpb 2021년 2월 23일
When you plot a fit object, it automatically adds a legend. For example, 'plot(myfit)', in which 'myfit' is the output of 'fit' would plot the fit line and a legend showing that line with the name "fitted". If you're plotting fit objects in a loop, the legend really slows it down, and, also, I don't want the legend. I tried removing the legends after the plot is done plotting, but the slow part is making the legends, so that doesn't help. Not sure if it's relevant, but this is in a plot with 42 subplots. I did some searching, but couldn't find this particular question asked before. Anyway to just not make the legend to begin with?

채택된 답변

dpb
dpb 2021년 2월 22일
편집: dpb 2021년 2월 23일
Doesn't seem to be any way to prevent the builtin fit object plot() routine from adding the legend.
Instead, use
plot(x,myfit(x),'linespec');
for the x that was the input to create myfit object. This will bypass the cfit object plot by evaluating it only and then call the base MATLAB plot() routine.
Does seem worthy of enhancement request to allow for further customization options on creation of fit object plots.
I didn't try to do comparison timings...

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by