Home  >  Article  >  How to customize legend in matlab

How to customize legend in matlab

藏色散人
藏色散人Original
2020-02-18 10:15:459402browse

How to customize legend in matlab

#How to customize the legend in matlab? How to add legend using code in Matlab?

As shown in the figure, first open the matlab software.

How to customize legend in matlab

As shown in the picture, click the red box check button to create a new file.

How to customize legend in matlab

Enter the following code.

x = 0:pi/50:2*pi;
y = sin(x);
y1=cos(x);
figure  
plot(x,y,'r')
hold on 
plot(x,y1,'b')

How to customize legend in matlab

#Get the graph as shown in the figure. You can see that this graph has no legend.

How to customize legend in matlab

As shown in the picture, add a line of code to the above code: legend('a','b');

How to customize legend in matlab

As shown in the figure, a legend has been added to the figure.

How to customize legend in matlab

For more programming-related content, please pay attention to the Programming Tutorial column on the php Chinese website!

The above is the detailed content of How to customize legend in matlab. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn