X-label additional text automatically.

조회 수: 2 (최근 30일)
Djordje Damnjanovic
Djordje Damnjanovic 2020년 12월 11일
댓글: Star Strider 2020년 12월 11일
Dear all,
I need help about Figures in Matlab. Is it posible to put on x-label two separate texts, for intance one in middle and one od the right edge of figure, but automaticly without command 'text'. For example like in the fig below (I marked it with the red circle):
If I use command xlabel for Frequency then I need to use comand text for (a) and in command tect I need to put cordinates and I do not want to do that for every figure. I need automatical way.
  댓글 수: 4
dpb
dpb 2020년 12월 11일
편집: dpb 2020년 12월 11일
" I need to do 30 different positioning of text, ..."
Why is it any different? Looks like the axes would be the same or at least very similar.
You have the x values in order to be able to plot the data, code them in, too...text() uses the axes coordinates for location; at worst you have to work out the y coordinate once to align it vertically where desired.
Djordje Damnjanovic
Djordje Damnjanovic 2020년 12월 11일
It is different because all 30 pictires are different, some are in time domain, some i frequency etc...All different values of x an y axis.
I can do this for example but I do not want in this way:
plot(t,sig,'LineWidth',1)
xlabel('{\it t} [s]','FontName','times','FontSize',8)
text(0.358,-39.4,'(a)','FontName','times','FontSize',8,'Color','k')
But in this way for every new figure coordinates in comand text are different and I need manual settings of this values each time and I do not want to do that, I want code for automatic positioning like in the second line of example xlabel.
If You know how to do that automaticly can write it down.

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

채택된 답변

Star Strider
Star Strider 2020년 12월 11일
Try something like this:
x = 1:10;
y = randn(1,10);
figure
plot(x,y)
xlabel('Frequency [Hz]')
text(max(xlim), min(ylim)-diff(ylim)*0.1, '(a)', 'HorizontalAlignment','right', 'VerticalAlignment','middle')
It seems to work correctly in my simulations, and appears to produce constant relative positioning of ‘(a)’.
  댓글 수: 6
Djordje Damnjanovic
Djordje Damnjanovic 2020년 12월 11일
Thanks a lot. It have manuel setting but not as my firts code so it is ok, I only need to change posmult like You said!
Thank You again!
Star Strider
Star Strider 2020년 12월 11일
As always, my pleasure!

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

추가 답변 (1개)

Djordje Damnjanovic
Djordje Damnjanovic 2020년 12월 11일
Anybody with sugestion?

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by