Set the same y axis scale on two plots

95 ビュー (過去 30 日間)
Luca Merolla
Luca Merolla 2020 年 7 月 11 日
編集済み: KLR 2020 年 7 月 11 日
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!

採用された回答

KLR
KLR 2020 年 7 月 11 日
編集済み: KLR 2020 年 7 月 11 日
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)|')

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by