필터 지우기
필터 지우기

Adding an Xlabel to a Semilogx plot?

조회 수: 12 (최근 30일)
Ashley
Ashley 2014년 2월 5일
편집: Azzi Abdelmalek 2014년 2월 5일
Hello, I plotted a semilogx plot because I want my x values to be in log scale. However, now, when I try to add an xlabel, I can't do it! I looked on the forums and found the following answer:
set(get(gca,'xlabel'),'units','pixels'); set(get(gca,'xlabel'),'Pos', [10 10]);
However, I tried this and this also does not work.
Any reason why and how do I overcome this? Thank you.
Ashley

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 5일
Look at this example
x=0:1000
y=sin(x)
plot(x,y)
set(gca,'xscale','log')
Now add xlabel
xlabel('you can do it')
  댓글 수: 2
Ashley
Ashley 2014년 2월 5일
Hello, This is a portion of my script that I'm using:
semilogx(frequency, phaseinmrad, '*') set(gca, 'XTickLabel', num2str(get(gca,'XTick')','%g')); xlabel('Frequency Hz');
but it won't label my x-axis. It keeps saying:
Index exceeds matrix dimensions.
Error in MagnetiteGraphs (line 13) xlabel('Frequency Hz');
That is the message it gives me. Please advise, Thank you.
Ashley
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 5일
편집: Azzi Abdelmalek 2014년 2월 5일
You probably used xlabel as a variable in your code. Try this to restore the functionality of xlabel
clear xlabel
xlabel('Frequency Hz');

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


the cyclist
the cyclist 2014년 2월 5일
편집: the cyclist 2014년 2월 5일
Are you able to post a small but self-contained example (i.e. code that we can run) that has everything except the xlabel you want, and describe a little more specifically what you want?
I have a feeling you mean xticklabel and not xlabel.
Here is a trivial example of an xlabel:
figure
semilogx(10.^(1:4),1:4);
xlabel('I am an x-label')

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by