フィルターのクリア

changing the legend line style (":","-","--","-.") for 4 black lines in plot instead of using multip colour

3 ビュー (過去 30 日間)
NOUFA
NOUFA 2022 年 7 月 2 日
コメント済み: NOUFA 2022 年 10 月 11 日
What should i add to appear the different black line style
figure;
plot([1:M]/M,u,'DisplayName','M='+string(M),'LineWidth',1); hold on;
xlabel('i/M','FontWeight','bold','FontSize',12);
ylabel('U','FontWeight','bold','FontSize',12);
lgd=legend;
lgd.NumColumns = 1;
lgd.FontSize = 12;
ax = gca;
ax.XAxis.FontWeight = 'bold';
ax.YAxis.FontWeight = 'bold';
  1 件のコメント
Jan
Jan 2022 年 7 月 2 日
Hint: [1:M] concatenates the vector 1:M with nothing. Slightly faster: (1:M) / M

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 7 月 2 日
figure;
axes('NextPlot', 'add', ...
'LineStyleOrder', cellstr([":", "-", "--", "-."]), ...
'ColorOrder', zeros(1, 3));
plot(rand(10, 4))
legend

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by