フィルターのクリア

How to Specify Line Color & Style

1 回表示 (過去 30 日間)
Ashwin Sivalingam
Ashwin Sivalingam 2019 年 4 月 23 日
コメント済み: Adam Danz 2019 年 4 月 23 日
Hi, I have created a scatterplot graph but am confused on how to incorporate how I can specify the line type for each variable. For example, If I add '-' to the scatterplot function, it ruins the whole graph. I would like for it to look like this:
Screenshot (2).png
But, my current code yields:
Screenshot (4).png
numVal =[2006 95 30 42 149
2007 109 33 43 164
2008 95 33 36 167
2009 95 42 39 209
2010 117 35 33 176
2011 114 29 39 147
2012 120 22 40 110
2013 126 30 44 151
2014 120 33 43 166];
figure;
title('Cholesterol Fall 2018');
scatter(numVal(:,1),numVal(:,2), 'filled','cyan');
hold on;
xlabel('year');
scatter(numVal(:,1),numVal(:,3), 'filled','r','o' );
scatter(numVal(:,1),numVal(:,4), 'filled','green','o');
scatter(numVal(:,1),numVal(:,5), 'filled','blue','d');
grid on;
legend('LDL Cholesterol','VLDL Cholesterol','HDL Cholesterol','Trygliycerides','Location','northwest')
title('Cholesterol Fall 2018');

採用された回答

Adam Danz
Adam Danz 2019 年 4 月 23 日
編集済み: Adam Danz 2019 年 4 月 23 日
Use plot() instead of scatter(). For example,
plot(numVal(:,1),numVal(:,4), 'g-o', 'markerfacecolor', 'g');
For a description of all line properties,
  4 件のコメント
Ashwin Sivalingam
Ashwin Sivalingam 2019 年 4 月 23 日
Your edited answer works, thanks!!
Adam Danz
Adam Danz 2019 年 4 月 23 日
I just added: 'markerfacecolor', 'g'
By 'messed up' you must have meant that the markers were not filled to the same color as the edges.
Glad it worked out!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by