How to have two legends on the same plot?
1 commentaire
Hi @ Miguel Martinez,
To address your query regarding, “ However, when using semilogy it didn't work”
First, generate some sample data for plotting. For this example, we will create two sets of data.
x = 1:10;
y1 = 10 ./ x;
y2 = log(x);
Plot the data using the semilogy function.
semilogy(x, y1, 'b', x, y2, 'r');
Add legends for both datasets using the legend function. To display two legends, you can use the legend function twice.
legend('Data 1', 'Data 2'); legend('Location', 'northwest'); % Adjust the location of the first legend
If you want, you can customize the legends further by specifying the location, font size, font weight, etc. For example:
legend('Data 1', 'Data 2', 'Location', 'northwest', 'FontSize', 10, 'FontWeight', 'bold');
Please see attached plot.

Réponses (2)
2 commentaires
Catégories
En savoir plus sur Legend dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

