How to change Marker Color in line graph?

53 ビュー (過去 30 日間)
Hassan Ashraf
Hassan Ashraf 2019 年 12 月 2 日
コメント済み: ME 2019 年 12 月 2 日
I am trying to change marker color of line graphs but unable to do it. Can anybody help to figure it out?
load('MCA_Disjoint.mat')
Data1LDA = MCA_Disjoint(: , 1);
Data2LDA = MCA_Disjoint(: , 3);
Data3LDA = MCA_Disjoint(: , 5);
WindowSizes = 50:25:450;
WindowSizes = WindowSizes';
f1=fit(WindowSizes,Data1LDA,'cubicinterp');
f2=fit(WindowSizes,Data2LDA,'cubicinterp');
f3=fit(WindowSizes,Data3LDA,'cubicinterp');
figure
hold on
p(1,:) = plot(f1,WindowSizes,Data1LDA);
p(2,:) = plot(f2,WindowSizes,Data2LDA);
p(3,:) = plot(f3,WindowSizes,Data3LDA);
set(p(1,2),'Color','red')
set(p(2,2),'Color','black')
set(p(3,2),'Color','blue')
set(p, 'LineWidth', 2, 'MarkerSize', 20)
  2 件のコメント
ME
ME 2019 年 12 月 2 日
Do you get a particular error message or does it just not produce anything?
Hassan Ashraf
Hassan Ashraf 2019 年 12 月 2 日
I am trying following methods but nothing is happening
1 ) Using this
set(p(1,2),'MarkerFaceColor ','red')
set(p(2,2),'MarkerFaceColor ','black')
set(p(3,2),'MarkerFaceColor ','blue')
2) OR using this
set(p, 'LineWidth', 2, 'MarkerSize', 20, 'MarkerFaceColor ' , ' red')

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

採用された回答

ME
ME 2019 年 12 月 2 日
Can you try the below and let us know what happens please? I don't have the necessary toolboxes to check it myself.
load('MCA_Disjoint.mat')
Data1LDA = MCA_Disjoint(: , 1);
Data2LDA = MCA_Disjoint(: , 3);
Data3LDA = MCA_Disjoint(: , 5);
WindowSizes = 50:25:450;
WindowSizes = WindowSizes';
f1=fit(WindowSizes,Data1LDA,'cubicinterp');
f2=fit(WindowSizes,Data2LDA,'cubicinterp');
f3=fit(WindowSizes,Data3LDA,'cubicinterp');
figure
hold on
pl1 = plot(f1,WindowSizes,Data1LDA);
pl2 = plot(f2,WindowSizes,Data2LDA);
pl3 = plot(f3,WindowSizes,Data3LDA);
set(pl1(2),'Color','red')
set(pl2(2),'Color','black')
set(pl3(2),'Color','blue')
set([pl1 pl2 pl3], 'LineWidth', 2, 'MarkerSize', 20)
  3 件のコメント
Hassan Ashraf
Hassan Ashraf 2019 年 12 月 2 日
Dont know how to change marker color from blue to black, red and blue for three lines respectively
ME
ME 2019 年 12 月 2 日
In that case, without being able to access the toolboxes to run the fit function I am unable to play around with this to get it doing what you want. I think I'm going to have to leave it to somebody else to help out.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by