# Plotting 1 set of data with two different axis - 1 reverse oriented

3 visualizzazioni (ultimi 30 giorni)
Patrik Micek il 6 Mag 2024
Commentato: Patrik Micek il 14 Mag 2024
Greetings, I am looking for a way to plot a set of data showcasing dispersion of the surface plasmon at the gold-air interface with two different x and y axis. Basically what I am trying to achieve is to plot angular frequency of the excitation wave, the wavevector, the wavelength of the incident EM field and the wavelength of the surface plasmon into one graph without having to plot a second set of data (in this case the wavevector vs wavelength). here is the code I use. Many thanks for the response in advance.
clear;
clc;
h_trans= 6.582119569e-16;
lambda0 = 450e-9;
c= 299792458;
omega_p_drude = 8.95./h_trans;
omega_0 = (2*pi.*c)./lambda0;
gama_drude = 0.0658./h_trans;
omega_p_interband = 2.96./h_trans;
gama_interband = 0.59./h_trans;
omega = linspace (1e+15,7e+15,1000)
k_0 = omega./(2*pi*c);
lambda = (2*pi*c./omega).*1e+9;
epsilon_d = 1;
epsilon_drude = 1- ((omega_p_drude^2)./(omega.^2+1i*gama_drude.*omega))% Drude model
epsilon_interband = 5+((omega_p_interband^2)./((omega_0^2-omega.^2)-1i*gama_interband.*omega)) %interband transitions
epsilon_r = epsilon_drude + epsilon_interband;
k_z = (((epsilon_r.*epsilon_d)./(epsilon_r+epsilon_d)).^(1/2)).*(omega./c)
k_z2 = (((epsilon_r.*epsilon_d)./(epsilon_r+epsilon_d)).^(1/2)).*(omega./c)
lambda_sp= ((((epsilon_d+epsilon_r)./(epsilon_d.*epsilon_r)).^(-1/2))).*lambda;
lambda_light_line = lambda.*epsilon_d;
figure (1)
hold on;
grid on;
yyaxis left;
plot (lambda,real(epsilon_r),'LineWidth',2);
xlabel ('Wavelength [m]');
ylabel ([char(949) '_{Real}' '[F/m]']);
%line([1250 1250],[-180 -75],'linewidth',2);
yyaxis right
plot (lambda,imag(epsilon_r),'r','linewidth',2);
ylabel ([char(949) '_{Im}' '[F/m]'])
hold on;
grid on;
figure (2)
hold on;
yyaxis left;
plot ((k_z),omega,'LineWidth',2);
plot (k_0,(omega),'r','LineWidth',2);
grid on;
ylabel ('\omega [Hz]')
xlabel ('k_{x} [m^{-1}]');
legend ('Au/air SPP','light line');
yyaxis right;
plot (k_z,lambda)
set(gca, 'YDir','reverse')
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

As per my understanding, you would like to merge both the figures 1 and 2 and plot both the components of Epsilon on the same axes. You can create 2 axes and set the x-axis location of one of them on top and y-axis on right. See example in the documentation link below:
After creating this alternate axes, you can assign this to Epsilon. Although this would mean that the scales of both real and imaginary compoenent are identical.
Also, since wavenumber and wavelength are inverseley proportional, we can also consider converting the Epsilon data as a function of wavevector and plot it in figure 2 with Kx [m^-1] as the X-axis.
Hope this helps!
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Patrik Micek il 14 Mag 2024
Perhaps I should have made myself more understandable.The plot for epsilon is allright. The issue is with the figure 2. Essentially, one of the y-axis is supposed to be angular frequency, which is actually there on the left side of the plot. However I'd like to plot the same data set but not in angular frequency units but wavelength (nm) which is now on the right side. For this however what I only managed to do is that I had to convert my wavevector values to wavelength as you mentioned and plot it. The thing is I do not want that yellow line in the graph. I am only interested in the wavelength scale that it is associated to on the right y axis of the plot.

Accedi per commentare.

### Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

R2024a

### Community Treasure Hunt

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

Start Hunting!

Translated by