How to edit my scatter plot legend?
古いコメントを表示
Hi,
I have a problem putting legend on my scatter plot.
I have used legend('Intact','Damage 1','Damage 2','Damage 3');
However, I want 'b*' to be my Intact, 'go' to be my Damage 1, 'k^' to be my Damage 2, and lastly 'rs' to be my Damage 3.
How do I change this?
Please see attached to have better understanding.
I hope I make sense. I really need help with this one
THANK YOU IN ADVANCE!!
Regards, Azra
2 件のコメント
Kuifeng
2016 年 4 月 18 日
for example, b*, your intact got 21 points, 1:5 is a 5 element vector. how would you like to plot 21 y values with 5 x values?
%similarly. other three groups
dpb
2016 年 4 月 23 日
From doc for plot "If one of Yn or Xn is a matrix and the other is a vector, it [i.e., PLOT] plots the vector versus the matrix row or column with a matching dimension to the vector." OP has his Y data in an array which in Matlab must be rectangular so there cannot be 21 points in the first array but an (indeterminate) number that is a multiple of 5 (the length of X vector). Since as you point out, there are 21 distinct points that N must be a minimum of 5; there could be more. It appears the data were collected with only two decimal digits of precision so either() there are NaN placeholders for missing values which *plot ignores silently or the other values are duplicated to other points in which case they're indistinguishable being overlaid identically.
Hence, there are N line objects for each array; these will be numbered sequentially and as noted above legend will associated text labels on a one-to-one basis with the first M lines if specific line handles are not provided for a differing association.
(*) Discounting the possibility there are other values outside the given plot limits that are thereby clipped from view...
採用された回答
その他の回答 (1 件)
Kuifeng
2016 年 4 月 18 日
plot(linspace(1,5,21), Intact..., 'b*',linspace(6,10,21), D1b..., 'go',...
linspace(11,15,21), D2b..., 'k^',linspace(16,20,21), D3b..., 'rs'). %note, may not be 21 elements.
legend...
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!