フィルターのクリア

any way to plot scatter-line with different symbol

1 回表示 (過去 30 日間)
Yu Li
Yu Li 2019 年 2 月 28 日
コメント済み: Star Strider 2019 年 2 月 28 日
is there anyway to draw a scatter-line figure with different symbol like below:
Thanks!
Yu

採用された回答

Star Strider
Star Strider 2019 年 2 月 28 日
編集済み: Star Strider 2019 年 2 月 28 日
To reproduce that figure, try this:
x = 1:6;
y = 1:6;
figure
plot(x(1:4), y(1:4), '-ok', 'MarkerFaceColor','k')
hold on
plot(x(4:5), y(4:5), '-k')
plot(x(5:6), y(5:6), '-ok', 'MarkerFaceColor','w')
hold off
axis([0 7 0 7])
EDIT — Added plot image:
any way to plot scatter-line with different symbol - 2019 02 28.png
Experiment to get the result you want.
  2 件のコメント
Yu Li
Yu Li 2019 年 2 月 28 日
Thank you.
Bests,
Yu
Star Strider
Star Strider 2019 年 2 月 28 日
As always, my pleasure.

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

その他の回答 (1 件)

dpb
dpb 2019 年 2 月 28 日
Not by controlling the 'marker' properties in a single scatter call, no, unfortunately. Those are global for the object.
It's simple-enough to do with plot and/or line, however...
hL=plot(A,B,'-k'); % draw the line, no markers full dataset
hold on % prepare to augment the plot
ixOn=[1:3]; % set the subset of one marker type/fill
hS(1)=scatter(A(ixOn),B(ixOn),'filled'); % draw the filled markers
hS(2)=scatter(A(~ixOn),B(~ixOn)); % and the unfilled ones
"Salt to suit..."
  2 件のコメント
Yu Li
Yu Li 2019 年 2 月 28 日
perhaps it should be:
clear all
close all
clc
A=1:7;
B=1:7;
hL=plot(A,B,'-k'); % draw the line, no markers full dataset
hold on % prepare to augment the plot
ixOn=[1:3]; % set the subset of one marker type/fill
hS(1)=scatter(A(ixOn),B(ixOn),'filled');
hold on% draw the filled markers
hS(2)=scatter(A(4:7),B(4:7));
I personally think would be better if the line do not cross the scatter circle .
untitled.jpg
dpb
dpb 2019 年 2 月 28 日
Your choice...the one draws the line piecemeal with the markers; the other just goes ahead and draws the line itself in "one swell foop" and then adds the markers...
The former takes the extra segment to join the two line segments; the latter just picks the desired marker style for the points and adds them on top of the existing line.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by