Adding variable values into legend
古いコメントを表示
Hello, i am looping over different valuesthat effect the plot and i can get a legend that shows how these values relate to the lines shown in the plot. However i would also like to add another legend or something similar that will show some parameters that are manually set in the program.
ie: If gravity would effect the shape of my plot and i set gravity to 10 i would like to be able to have it show on the firgure that "10" was the value of gravity used for run of the plot
thanks
採用された回答
その他の回答 (2 件)
Da Bu
2021 年 4 月 22 日
Maybe this code can help you:
x = 1:.1:3;
colors = jet(5);
for n = 1:5
plot(x,sin(x)*n,'color',colors(n,:),'DisplayName',strcat('gravity=',num2str(n)))
hold on;
end
legend('show')
2 件のコメント
TANMOY BAIRAGI
2022 年 1 月 10 日
That's a great technique, thanks a lot.
Michael O'Brien
2023 年 3 月 13 日
you beautiful human being, you x
Shubhankar
2023 年 4 月 25 日
1 投票
your codes works perfect, but could you be kind enough to give the explanation of legend('show')?
and what exactly you are doing in the plot command?
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!