Home >Common Problem >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.
As shown in the picture, click the red box check button to create a new file.
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')
#Get the graph as shown in the figure. You can see that this graph has no legend.
As shown in the picture, add a line of code to the above code: legend('a','b');
As shown in the figure, a legend has been added to the figure.
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!