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

40 vues (au cours des 30 derniers jours)
Louis Tomczyk
Louis Tomczyk le 24 Mai 2022
Commenté : Louis Tomczyk le 25 Mai 2022
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)

Réponse acceptée

Voss
Voss le 24 Mai 2022
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 commentaires
Voss
Voss le 24 Mai 2022
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 le 25 Mai 2022
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by