How do I display certain data on top of others using multiple Scatter plots

17 ビュー (過去 30 日間)
Steven Yeh
Steven Yeh 2021 年 8 月 2 日
コメント済み: Steven Yeh 2021 年 8 月 3 日
scatter(real(SGG(ids)),imag(SGG(ids)),10,[0 1 0],'filled');
hold on
for abc=1:M
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),35,[0 0 1],'filled');
end
scatter(real(SRR(idx)),imag(SRR(idx)),10,[1 0 0],'filled');
xlabel('Real Part');
ylabel('Imaginary Part');
title('ACE For MaxMin');
legend([scatter(real(SGG(ids)),imag(SGG(ids)),10,[0 1 0],'filled'), ...
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),15,[0 0 1],'filled'),...
scatter(real(SRR(idx)),imag(SRR(idx)),10,[1 0 0],'filled')],'Correct-Decoded Signal','QPSK Signal','Error-Decoded Signal');
xlabel('Real Part');
ylabel('Imaginary Part');
title('ACE For MaxMin');
hold off
The above are the codes that I used to create multiply scatter plots, but everytime the second scatterplot's data gets overlapped by the other scatterplots.
for abc=1:M
scatter(1*cos((2*abc-1)*pi/M),1*sin((2*abc-1)*pi/M),35,[0 0 1],'filled');
end
This is the scatter plot data that I want to display at the very top without other data overlapping it, is there a way to do that?

採用された回答

Dave B
Dave B 2021 年 8 月 2 日
You can manipulate the stacking order in the axes by changing the order of the axes children vector or using the ustack function:
ax=gca;
h1=scatter(ax,rand(1000,1),rand(1000,1),100,'filled','r');
hold on
h2=scatter(ax,rand(1000,1),rand(1000,1),100,'filled','b');
ax.Children=[h1;h2]; % display the red one on top of the blue one
uistack(h1); % display the red one on top
Note: your call to legend is suspicious, it looks like you're making additional scatters (?) If you capture the output of the scatters in a variable, you can pass that variable to legend rather than calling scatter again.
  1 件のコメント
Steven Yeh
Steven Yeh 2021 年 8 月 3 日
Thanks a lot, this works perfectly, and thanks for correcting my code, the scatter in legend did seem redundant, I’ve set new variables to each scatter and everything works. Thanks a lot again!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by