Labelling 3 different x and y points with on thefigure without any confusion

1 回表示 (過去 30 日間)
Hello I have a csv file that receives wavelength intensity values and for the csv file I have not any problem. My problem is that I have defined the values for the a = [247 309 324] ; these values are on x axes and for the b = [5.7 90.5 345.1] on y axes; so wavelength 247 has 5.7 intensity sameway it follows 309 90.5 and 324 345.1. But I have problem on labelling these 3 points and I have also problem with legend(names). Lastly, as you can see on the figure it should labels the only C-1 Al-1 Cu-1 with different markers but the big red dot doesn't symbol my Al-1 the star Al-1 and the red dot is different.

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 24 日
ext() objects are included in legend() .
You need to record the handles returned by plot(). Then you call legend() and as the first parameter to legend() you pass the handles of the graphics objects you are creating legend entries for.
When you plot(a,b,'*') you are generating a single line() object with three markers that are all the same.
line() objects and scatter() objects have the same difficulty that each line and each scatter plot can only have a single marker shape and color assigned to it. If you need different marker shapes or colors for your three a, b points then you will need to make three calls to plot() or scatter()
  3 件のコメント
Onur Hakverdi
Onur Hakverdi 2021 年 6 月 24 日
編集済み: Onur Hakverdi 2021 年 6 月 24 日
the problem with the data Al peak point and assigned Al value it is becoming confused.
x1 = [247]; y1 = [5.7];
x2 = [309]; y2 = [90.5];
x3 = [324]; y3 = [345.1];
hold on
plot(x1,y1,'*')
plot(x2,y2,'^')
plot(x3,y3,'h')
legend('C-1','Al-1','Cu-1')
Onur Hakverdi
Onur Hakverdi 2021 年 6 月 24 日
I think I solved the problem randomly :)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by