Adding a second x-axis to the top

조회 수: 100 (최근 30일)
Zihad Azad
Zihad Azad 2020년 2월 17일
댓글: Ahmed Hassebo 2020년 9월 22일
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]);

답변 (1개)

Ajay Kumar
Ajay Kumar 2020년 2월 17일
  댓글 수: 2
Zihad Azad
Zihad Azad 2020년 2월 17일
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 2020년 9월 22일
Remove this line from the second code
% line(l*1e7,y,'Parent',ax2,'Color','k','linewidth',2);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by