필터 지우기
필터 지우기

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

조회 수: 35 (최근 30일)
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 CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by