Effacer les filtres
Effacer les filtres

Set the same y axis scale on two plots

98 vues (au cours des 30 derniers jours)
Luca Merolla
Luca Merolla le 11 Juil 2020
Modifié(e) : KLR le 11 Juil 2020
Hello everyone!
I have two FFT plots and the y-axes are scaled differently: on one, the numbers are multiplied x10^-5, and on the other x10^-6. How can I plot both axes on the same scale, for example x10^-6, for a better comparison? Attached there's an image that shows the different scales on the y-axis, and here is the code that generates the figure:
figure;
subplot(1,2,1)
plot(f_b, P1_b)
title('FFT for baseline')
xlabel('Frequency')
ylabel('|P1(f)|')
subplot(1,2,2)
plot(f_e, P1_e)
title('FFT for experimental condition')
xlabel('Frequency')
ylabel('|P1(f)|')
Also because after that, I'm planning to get the area under the curve, so it would be easier to have the signals on the same scale.
I hope I was clear enough. Thank you very much in advance for your help!

Réponse acceptée

KLR
KLR le 11 Juil 2020
Modifié(e) : KLR le 11 Juil 2020
Since you are using subplots to plot the data you can use link axis to link the desired axis. Here's the link that explains in more detail. https://www.mathworks.com/help/matlab/ref/linkaxes.html
Or you can manually set the Ylimits for instance in your plot
figure;
subplot(1,2,1)
plot(f_b, P1_b)
title('FFT for baseline')
xlabel('Frequency')
ylabel('|P1(f)|')
subplot(1,2,2)
plot(f_e, P1_e)
% Add a line here to set the y limits
ylim([minimumvalue maximumvalue]) % specify the minimum and maximum value so that both the y axis have the same scale
title('FFT for experimental condition')
xlabel('Frequency')
ylabel('|P1(f)|')

Plus de réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by