Aligning a linear and non-linear x-axis
I have a spectroscopy plot of two curves, one relating to wavelength and one to wave number.
Wavenumber = 1/wavelegnth, so the relation is non linear. I want to align the top x-axis with bottom x-axis so that the peaks of the two curves are displayed in line with each other. Is this possible?
This is my current code:
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,wl1,sol1,’-r’,’LineWidth’,3)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax1.XColor = ‘r’;
ax1.YColor = ‘r’;
set(ax1, ‘xlim’,[300 400])
xlabel(‘wavelength (nm)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
hold on
ax2 = axes(t);
plot(ax2,wn1,sol1_adj,’-k’,’LineWidth’,3)
set(ax2, ‘xlim’,[250000 333333])
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
xlabel(‘wavenumber(m^-^1)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
set(gca, ‘XDir’,’reverse’)
ax1.FontSize = 16;
ax2.FontSize = 16;I have a spectroscopy plot of two curves, one relating to wavelength and one to wave number.
Wavenumber = 1/wavelegnth, so the relation is non linear. I want to align the top x-axis with bottom x-axis so that the peaks of the two curves are displayed in line with each other. Is this possible?
This is my current code:
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,wl1,sol1,’-r’,’LineWidth’,3)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax1.XColor = ‘r’;
ax1.YColor = ‘r’;
set(ax1, ‘xlim’,[300 400])
xlabel(‘wavelength (nm)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
hold on
ax2 = axes(t);
plot(ax2,wn1,sol1_adj,’-k’,’LineWidth’,3)
set(ax2, ‘xlim’,[250000 333333])
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
xlabel(‘wavenumber(m^-^1)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
set(gca, ‘XDir’,’reverse’)
ax1.FontSize = 16;
ax2.FontSize = 16; I have a spectroscopy plot of two curves, one relating to wavelength and one to wave number.
Wavenumber = 1/wavelegnth, so the relation is non linear. I want to align the top x-axis with bottom x-axis so that the peaks of the two curves are displayed in line with each other. Is this possible?
This is my current code:
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,wl1,sol1,’-r’,’LineWidth’,3)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax1.XColor = ‘r’;
ax1.YColor = ‘r’;
set(ax1, ‘xlim’,[300 400])
xlabel(‘wavelength (nm)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
hold on
ax2 = axes(t);
plot(ax2,wn1,sol1_adj,’-k’,’LineWidth’,3)
set(ax2, ‘xlim’,[250000 333333])
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
xlabel(‘wavenumber(m^-^1)’,FontSize=18)
ylabel(‘Absorption’,FontSize=18)
set(gca, ‘XDir’,’reverse’)
ax1.FontSize = 16;
ax2.FontSize = 16; axis, scaling MATLAB Answers — New Questions