Reputation: 177
The plotting code is shown as:
figure;
snr_idx = 1:2:7;
for n = 1:4
subplot(2,2,n);
ith = snr_idx(n);
xx_cpd(:,n) = reshape(theta_est_s1(1,ith,:,1), 500,1);
yy_cpd(:,n) = reshape(theta_est_s1(2,ith,:,1), 500,1);
scatter(xx_cpd(:,n), yy_cpd(:,n), 30, 'o', 'LineWidth', 5e-5)
grid on
xlabel('\phi_1 (deg)','fontsize',12)
ylabel('\phi_2 (deg)','fontsize',12)
title(['SNR = ',num2str(SNRvec(ith)), 'dB' ])
end
Where SNRvec
is a vector as: [-3 0 3 6 9 12 15].
theta_est_s1
is a four-dimensional array, the size of theta_est_s1
is 2×7×500×3.
Then the resulting figure is shown as following:
However, the contrast between each subplot is not remarkable enough. I want all the subplots have the same axis setting as the first subplot, i.e. when the first subplot is made, the axis is fixed, which is shown as:
If I use axis([60 70 110 120])
command in this example, the resulting figure is correct. Nevertheless, the range of theta_est_s1
is not fixed. When the input data is changed, the maximum and minimum of theta_est_s1
are changed a lot. Therefore I cannot merely set the axis manually in a direct way.
Is there any method to figure out this issue?
Thanks!
Upvotes: 0
Views: 437
Reputation: 13945
Here is an idea if I got your question right:
Since MATLAB automatically resizes the axis to fit with the range of the data, you can let it set the limit for the first plot only, and then in each subsequent plot retrieve the x- and y limits and assign them to every subplot.
Example with your code:
figure;
snr_idx = 1:2:7;
for n = 1:4
subplot(2,2,n);
ith = snr_idx(n);
xx_cpd(:,n) = reshape(theta_est_s1(1,ith,:,1), 500,1);
yy_cpd(:,n) = reshape(theta_est_s1(2,ith,:,1), 500,1);
scatter(xx_cpd(:,n), yy_cpd(:,n), 30, 'o', 'LineWidth', 5e-5)
%// Get the axis limits after the 1st plot
if n == 1
X_axis_lim = get(gca,'XLim')
Y_axis_lim = get(gca,'YLim')
else %// After 1st iteration, adjust limits
set(gca,'XLim',X_axis_lim);
set(gca,'YLim',Y_axis_lim);
end
grid on
xlabel('\phi_1 (deg)','fontsize',12)
ylabel('\phi_2 (deg)','fontsize',12)
title(['SNR = ',num2str(SNRvec(ith)), 'dB' ])
end
Upvotes: 1