Seeking Help for Scatter Plots

1 回表示 (過去 30 日間)
A M
A M 2017 年 8 月 19 日
編集済み: Star Strider 2017 年 8 月 19 日
Hi, i am trying to make a scatter plot as scatter(x,y). However, how to pass multiple values along y-axis against each respective x-axis index? For example, at x=1, i want to plot two corresponding y values as (2) and (3).

回答 (1 件)

Star Strider
Star Strider 2017 年 8 月 19 日
編集済み: Star Strider 2017 年 8 月 19 日
This is easier to do with plot than with scatter:
x = 1:5;
y = [2 3 NaN; 5 2 4; 3 NaN NaN; 6 5 3; 1 3 4]; % Matrix With Multiple ‘y’ Values For Each ‘x’
figure(1)
plot(x, y, 'pg')
grid
axis([0 6 0 10])
EDIT
If you absolutely must use scatter, this works:
x = [1 1 2 2 2 3 4 4 4 5 5 5];
y = [2 3 5 2 4 3 6 5 3 1 3 4];
figure(1)
scatter(x, y, 'pg')
grid
axis([0 6 0 10])
The plot option is easier.

カテゴリ

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