![]() |
MATLAB provides the legend() function to add legends to a set of axes, which makes legend-making easy and efficient. In this article, we shall see how to add legends to single and multiple cartesian axes in MATLAB with various examples. Syntax:
Now, the labels could be either string, string vectors, or a cell array. Adding legend to a simple sine and cosine function plot. Example 1: Matlab
Output: ![]()
Adding legend with cell arrays. Example 2: Matlab
Output: ![]()
Now, let us add different legends to multiple axes in the same figure. Example 3: Matlab
Output: ![]()
For changing the location of axes in the graph, we can use the ‘Location’ parameter and specify the location as ‘northeast’, ‘south’ etc. Let us see an example, where we move the legend from northeast to north. Example 4: Matlab
Output: ![]()
|
Reffered: https://www.geeksforgeeks.org
MATLAB |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |