Is is possible to name a plot and attain a legend in MATLAB? [duplicate]

StackOverflow https://stackoverflow.com/questions/22176246

  •  03-06-2023
  •  | 
  •  

سؤال

I have several plots in a MATLAB code. But handling the legend colors each time is painful. Is there a way to name plots such as plot1=... and then using this name attaina color to a corresponding legend?

هل كانت مفيدة؟

المحلول

Yes:

plot1 = plot(x,y);
legend(plot1, 'series 1', 'series 2');

plot1 is called the figure handle

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top