フィルターのクリア

Scatter Plot only Non-Zero Set of Points

15 ビュー (過去 30 日間)
CMatlabWold
CMatlabWold 2020 年 5 月 5 日
コメント済み: CMatlabWold 2020 年 5 月 6 日
Hi,
I suppose... Let's say, once you make two tables of values and you decide create a scatter plot, where the row values of one table is plotted against the row values the other... how can you use scatter to plot only the non-zero points in the tables?
For instance,
I had:
x1 = tt5{:,6}
y1 = ss5{:,6}
scatter(x1,y1,'b')
hold on
where
ss5 column 6:
0
1
0
0
1
0
0
0
tt5 column 6:
0
7
6
5
18
6
4
5
So, I would only want to plot (7,1) and (18,1)
  6 件のコメント
Rik
Rik 2020 年 5 月 5 日
Either will do ;)
It is just a bit frustrating to apply formatting to your question, and then having to do it again because you removed everything including the formatting. The edit controls are right there when you edit you posts, please use them.
CMatlabWold
CMatlabWold 2020 年 5 月 5 日
lol I get it

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

採用された回答

Sindar
Sindar 2020 年 5 月 5 日
Here's how to do this with a small example script:
% create a 5x2 array of random integers 0-5 for both x and y
x = randi([0 5],5,2);
y = randi([0 5],5,2);
% identify indices where both x and y are not zero
idx = (x ~= 0) & (y ~= 0);
% plot only these
scatter(x(idx),y(idx))
If this doesn't work with your code, please work to simplify it as Rik suggests
  5 件のコメント
Sindar
Sindar 2020 年 5 月 5 日
編集済み: Sindar 2020 年 5 月 5 日
look at the plot, those are 1's. It will look better if you change the ylim:
% get current limits
yl=ylim();
% set new bottom limit to 0
ylim([0 yl(2)])
CMatlabWold
CMatlabWold 2020 年 5 月 6 日
You are right. Thank you!

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

その他の回答 (0 件)

カテゴリ

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