Effacer les filtres
Effacer les filtres

Adding a second x-axis to the top

86 vues (au cours des 30 derniers jours)
Zihad Azad
Zihad Azad le 17 Fév 2020
Commenté : Ahmed Hassebo le 22 Sep 2020
Hello dear altruist,
in need of help here. I need to add a second x-axis to the top of my graph here:
The x-axis values at the top is just the inverse of the variable below (2*pi/kx). This would help me visualize the data both in terms of wavevector and wavelength. The codes and files are attached herwith. Thanks in advance.
clc; clear all;
load infinite;
% transpose matrix is not required
A1= log10(fs1);
kx=ky;
h1=figure
p1=pcolor(kx*1e-6,f/1e12,A1);
xlabel('\it{k_x} (\rm{\times10^6 m^{-1}})') ;ylabel('{\itf} (THz)');
ylim([33 1600]);
set(h1, 'Units', 'normalized');
get(h1, 'Position');
set(h1,'Position',[ 0.12 0.22 0.18 0.33]);
%colormap setting needs to come after each subplot
shading interp;
colormap jet(500);%colormap need to be set to jet for Blue-yellow-red map
%font properties
FS='Fontsize';
fs1=20;
fs2=20;
FN='Fontname';
fn='Times New Roman';
set(findall(gcf,'type','axes'),FS,fs1,FN,fn);
set(findall(gcf,'type','text'),FS,fs2,FN,fn);
x0=100;
y0=100;
width=700;
height=500;
set(gcf,'units','pixels','position',[x0,y0,width,height]);

Réponses (1)

Ajay Kumar
Ajay Kumar le 17 Fév 2020
  2 commentaires
Zihad Azad
Zihad Azad le 17 Fév 2020
Thanks. But using this I have run into another problem. Basically, I am using this to plot a curve of zeros:
How do I get rid of the line plot in the middle?
The code:
clc; clear all;
load infinite;
% transpose matrix is not required
A1= log10(fs1);
kx=ky;
h1=figure
p1=pcolor(kx*1e-6,f/1e12,A1);
xlabel('\it{k_x} (\rm{\times10^6 m^{-1}})');ylabel('{\itf} (THz)');
ylim([33 1600]);
set(h1, 'Units', 'normalized');
get(h1, 'Position');
set(h1,'Position',[ 0.12 0.22 0.18 0.33]);
%colormap setting needs to come after each subplot
shading interp;
colormap jet(500);%colormap need to be set to jet for Blue-yellow-red map
ax1 = gca; % current axes
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,'XAxisLocation','top','YAxisLocation','right','Color','none','YTick',[],'TickLength',[.00014 .0014]);
xlabel(ax2,'\rm lambda(\mum)');
l=(2*pi)/ky;
L=length(l);
y=zeros(L);
line(l*1e7,y,'Parent',ax2,'Color','k','linewidth',2);
set(ax2,'XDir','reverse');
% set(gcf,'visible','off');
%font properties
FS='Fontsize';
fs1=20;
fs2=20;
FN='Fontname';
fn='Times New Roman';
set(findall(gcf,'type','axes'),FS,fs1,FN,fn);
set(findall(gcf,'type','text'),FS,fs2,FN,fn);
x0=100;
y0=100;
width=700;
height=500;
set(gcf,'units','pixels','position',[x0,y0,width,height]);
Ahmed Hassebo
Ahmed Hassebo le 22 Sep 2020
Remove this line from the second code
% line(l*1e7,y,'Parent',ax2,'Color','k','linewidth',2);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Red dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by