Home > Common Problem > body text

How to customize legend in matlab

藏色散人
Release: 2020-02-18 10:15:45
Original
9428 people have browsed it

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')
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template