Changing the marker type for the nth entry in plot

I've been working on a project where we are changing 2 variables and the outputs are T values and Y values. Here's pretty much what the data looks like.
T1 = [1;3;5;7];
T2 = [0.9;2.7;5;6.8];
T3 = [1;2.9;5.1;7];
Y1 = [1;2;1;2];
Y2 = [4;5;6;4];
Y3 = [7;8;7;7];
figure;
hold on;
plot(T1,Y1,':');
plot(T2,Y2,'-.');
plot(T3,Y3,'--');
As you can see all the X values pretty much line up around 1,3,5, and 7. I want each plot to not only have a unique line, but to have the nth entry to be a certain marker style, so all second entries (around X=3) to have a square marker for example. So you should be able to identify a point by its line style and marker style. Therefore, I would like the legend to have a label for each line style and marker style. So something like this:
legend('line style 1','line style 2','line style 3','marker style 1','marker style 2','marker style 3','marker style 4');
Thanks

 採用された回答

Brendan Hamm
Brendan Hamm 2015 年 7 月 1 日

0 投票

You would have to accomplish this as a second plot, since each Line has a MarkerStyle associated with all of the data points. To do this for the 3rd entry:
T1 = [1;3;5;7];
T2 = [0.9;2.7;5;6.8];
T3 = [1;2.9;5.1;7];
Y1 = [1;2;1;2];
Y2 = [4;5;6;4];
Y3 = [7;8;7;7];
figure;
ax = axes;
hold on;
plot(T1,Y1,':');
plot(T2,Y2,'-.');
plot(T3,Y3,'--');
ax.ColorOrderIndex = 1; % Return to the previous color index
n = 3; % The nth element should be plotted as a square
plot(T1(n),Y1(n),'s');
plot(T2(n),Y2(n),'s');
plot(T3(n),Y3(n),'s');

1 件のコメント

Louis
Louis 2015 年 7 月 1 日
Great idea - this even makes the legend very easy to set.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

質問済み:

2015 年 7 月 1 日

コメント済み:

2015 年 7 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by