MATLAB Answers

How to label on top and bottom side of the figure

조회 수: 20(최근 30일)
Hello, I have created the plotand I want to label the axis on both top and bottom side of the plot.kindly help me .
Thanks in advance

답변(1개)

Srivardhan Gadila
Srivardhan Gadila 22 Mar 2021
You can refer to the following answer: Is it possible to plot the data and show two different scales for the same data using MATLAB 7.9 (R2009b)? and change the code to have another X-axis in the top instead of the Y-axis on the right by using setting XAxisLocation to 'top'and using xlabel for the 2nd axis.
y = 0:0.01:20;
x = 200*exp(-0.05*x).*sin(x);
f = figure;
a1 = axes;
plot(x,y)
xt = get(a1,'XTick');
a2 = copyobj(a1,f);
set(a2,'Color','none')
set(a2,'Ytick',[])
set(a2,'XAxisLocation','top')
converted_values = 2.54*xt;
set(a2,'XTickLabel',converted_values)
xlabel(a1,'X [inches]')
ylabel(a1,'Y [units]')
xlabel(a2,'X [cms]')
  댓글 수: 1
HARIKRISHNA B YADULADODDI
Thank you for your reply for my question. I will try your suggestion.

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

Community Treasure Hunt

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

Start Hunting!

Translated by