Info

This question is closed. Reopen it to edit or answer.

Dual parallel X axis scale

1 view (last 30 days)
Doyinsola
Doyinsola on 1 May 2024
Closed: Doyinsola on 2 May 2024
Hi guys, please help review the script below.
I am making a plot with a dual x-axis (in nm and cm-1). The goal is to make a plot of Intensity vs wavelength in nm but at the same time have the wavelength scale in wavenumber parallel to each other. With my current script, the axes doesn't correspond well, for example: 2500nm correspoonds to 4000 cm-1 but what I got doesn't corresponds to this. See image below.
#script
wavenumber = 1e7 ./ wv11;
figure;
plot(wv11, miroptimized(2:end-1,:)); % Plot intensity vs wavelength
xlabel('Wavelength (nm)');
ylabel('Intensity');
ax2 = axes('Position', get(gca, 'Position')+[0, -0.03, 0, 0], 'Color', 'none', 'YTick', [], 'XAxisLocation', 'bottom', 'XLim', [min(wv11), max(wv11)], 'NextPlot', 'add');
xlabel(ax2, 'Wavenumber (cm^{-1})');
ax2.XLim = [min(wavenumber), max(wavenumber)];
ax2.Position = get(gca, 'Position')+[0, -0.03, 0, 0];
set(gca, 'Box', 'off', 'Color', 'none');
set(ax2, 'Box', 'off');

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!