How to subplot 2 constellations with scatterplot (and NOT "scatter plot")

37 ビュー (過去 30 日間)
Louis Tomczyk
Louis Tomczyk 2022 年 5 月 24 日
コメント済み: Louis Tomczyk 2022 年 5 月 25 日
Dear all,
I am trying to plot constellations (numerical communications).
The attached file (test.mat) give 4 matrices: the waveformi with i=1,2,3,4 from which we reconstruct the signal.
I would like to plot in a SAME figure using the built-in function "scatterplot".
How do the trick with the "scatterplot" and subplots built-in functions?
(I want to precise, I DON'T WANT to use "scatter plot"..
I know how to do a "hand-made" scatter plot with real an imaginary parts, but we need to normalise and work the layout by hand...)
Thanks in advance!
The small code is:
% loading the measured data
load test.mat
% reconstruction of the signals
x = waveform1+1i*waveform2;
y = waveform3+1i*waveform4;
% plotting
figure
subplot(1,2,1)
scatterplot(x)
subplot(1,2,2)
scatterplot(y)

採用された回答

Voss
Voss 2022 年 5 月 24 日
As far as I can tell, there is no way to use scatterplot to create a scatter plot in a subplot (or in any axes other than the one scatterplot creates), but maybe the following approach can work. The idea is to create the scatter plots using the scatterplot function, then copy the graphics objects to a common figure.
% loading the measured data
load test.mat
% reconstruction of the signals
x = waveform1+1i*waveform2;
y = waveform3+1i*waveform4;
% figure where two scatterplots will end up:
f = figure('Color',[0 0 0]);
scatter_fig = scatterplot(x); % create scatterplot
copyobj(get(scatter_fig,'Children'),f); % copy everything from scatterplot figure to f
delete(scatter_fig); % delete scatterplot figure
scatter_fig = scatterplot(y); % create scatterplot
copyobj(get(scatter_fig,'Children'),f); % copy everything from scatterplot figure to f
delete(scatter_fig); % delete scatterplot figure
% re-position the two axes in figure f:
ax = findall(f,'Type','axes');
set(ax(2),'Position',[0.1 0.11 0.38 0.815]);
set(ax(1),'Position',[0.6 0.11 0.38 0.815]);
  3 件のコメント
Voss
Voss 2022 年 5 月 24 日
You're welcome!
I agree the solution I came up with is not very general. However, it's possible to adapt the last part, where the axes' Positions are set:
% re-position the two axes in figure f:
ax = findall(f,'Type','axes');
set(ax(2),'Position',[0.1 0.11 0.38 0.815]);
set(ax(1),'Position',[0.6 0.11 0.38 0.815]);
to handle any number and arrangement of axes, similar to how subplot does it.
Louis Tomczyk
Louis Tomczyk 2022 年 5 月 25 日
Finally I wrote my own function to display the constellations with scatter plot instead as it is easier to set the locations and axis properties to my mind.
It takes varying number of polarisation-multiplexed (or not) signals in argument.
If it can be useful for some.
Thanks again for your help!
Best,
louis

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by