How to align the figure name to the left ?

조회 수: 153 (최근 30일)
aurora
aurora 2012년 10월 12일
편집: Adam Danz 2023년 11월 21일
Hi,
How can I align the figure name or title to the left side ?
Thanks in advance
  댓글 수: 6
Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 12일
aurora, how did you creat this name?
aurora
aurora 2012년 10월 12일
figH=figure();
set(figH,'name','mytitle','NumberTitle','off');

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

채택된 답변

Matt Fig
Matt Fig 2012년 10월 12일
About the only thing I can think of is to buffer with spaces, but then resizing the figure wouldn't preserve this.
set(gcf,'name',' Myfig')
  댓글 수: 2
aurora
aurora 2012년 10월 12일
편집: aurora 2012년 10월 12일
Thank u @Matt Fig it's a good idea, actually it worked fine with me , but if someone else operate my file on his system then it'll appear right to him . I thought I'll find a figure property doing that , I'll better change my system language . thanks
Lucien Robinault
Lucien Robinault 2018년 3월 13일
It look like you could try to use html to do this as explained here : https://undocumentedmatlab.com/blog/aligning-uicontrol-contents

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

추가 답변 (6개)

Adam Danz
Adam Danz 2023년 4월 18일
편집: Adam Danz 2023년 11월 21일
Starting in MATLAB R2020b, control the horizontal alignment of title and subtitle using the axis properties TitleHorizontalAlignment which can be set to center (default), left, or right.
Similarly, control the alignment of axis labels using the LabelHorizontalAlignment which is a property on the axis ruler.
For demos, see this Community Highlight.
(This does not affect the position of the figure name which is the original question by the OP).
tiledlayout(1,3)
ax1 = nexttile();
title('Left')
ax1.TitleHorizontalAlignment = 'left';
box on
axis square
grid on
ax2 = nexttile();
title('Center')
ax2.TitleHorizontalAlignment = 'center';
box on
axis square
grid on
ax3 = nexttile();
title('Right')
ax3.TitleHorizontalAlignment = 'right';
box on
axis square
grid on

Dimitrios Patikas
Dimitrios Patikas 2022년 8월 27일
There is no way I know for adjusting the title of the figure.
The title of each graph can be adjucted by calculating the limits of the axes. For example:
subplot(3,1,1)
plot([1:pi/10:10], sin(1:pi/10:10))
LimitsX = xlim; LimitsY = ylim;
title('Left', 'HorizontalAlignment', 'left', 'position', [LimitsX(1), LimitsY(2)]);
subplot(3,1,2)
plot([1:pi/10:10], cos(1:pi/10:10))
LimitsX = xlim; LimitsY = ylim;
title('Center (default)');
subplot(3,1,3)
plot([3:pi/10:12], sin(3:pi/10:12))
LimitsX = xlim; LimitsY = ylim;
title('Right', 'HorizontAlalignment', 'right', 'position', [LimitsX(2), LimitsY(2)]);
  댓글 수: 1
O.Hubert
O.Hubert 2023년 3월 28일
편집: O.Hubert 2023년 3월 28일
Although this answer does not address the issue of the OP (which was to change the location of the figure name and not the title of the plot, i.e. having "Figure 1" left-aligned), this answer addresses the issue of setting the title plot aligned with the plot area, which may be the reason why users land on this thread.
It is a nice solution which does not require any ad-hoc setting of the location.

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


Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 12일
title('yourtitle','position',[1 1])
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 12일
Aurore why are you changing the location of the name?
aurora
aurora 2012년 10월 12일
what do you mean ? if you mean why I want to change the name to the left is because I want my project interface figure to be in a good appearance

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


Mohamed Marei
Mohamed Marei 2013년 5월 11일
편집: Azzi Abdelmalek 2013년 5월 11일
This is long overdue but I figured someone else might heed to do it:
set(title1,'Position',[4.98848 0.24 1.00011]) %%%Default setting
set(title1,'Position',[4.98848 0.34 1.00011]) %%%Shifts upward by 0.1 units
set(title1,'Position',[5.98848 0.34 0.00011]) %%%Shifts to the left by 1 unit
  댓글 수: 1
Jonathan Broyles
Jonathan Broyles 2017년 4월 21일
When I tried it this way, but when I pan the plot(change xlim or ylim) the title moves with it, rather than staying stationary as you would expect a title to do. R2017a

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


Roger Parkyn
Roger Parkyn 2020년 9월 14일
Or just use a text label instead.
text(0.02, 1.02, 'Some Title String', 'Units', 'normalized', 'VerticalAlignment','Bottom', 'FontWeight','bold');

Sara
Sara 2021년 3월 23일
You can change the psition based on your need by chnaging the
[0.5 1200 1.1]);
I used this in one of my codes.
title ('a','FontSize',13,'position',[0.5 1200 1.1]);
%
%

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by