How to add a description text on top of a plot without it being written all of my plot
조회 수: 48 (최근 30일)
이전 댓글 표시
How to add a description text on top of a plot without it being written all of my plot ?
here is my code just run it to understand what I mean.
is it possible to translate the plot to the bottom?
FigH = figure;
plot(1:10)
AxesH = axes('Parent', FigH, ...
'Units', 'normalized', ...
'Position', [0, 0, 1, 1], ...
'Visible', 'off', ...
'XLim', [0, 1], ...
'YLim', [0, 1], ...
'NextPlot', 'add');
chr = 'I wanna add a description';
chr = [chr newline 'On top of the plot']
TextH = text(0,1, chr , ...
'HorizontalAlignment', 'left', ...
'VerticalAlignment', 'top');
댓글 수: 2
Adam Danz
2019년 5월 10일
I formatted your code. In the future, please use the formatting tools to add code. Thanks.
채택된 답변
Adam Danz
2019년 5월 10일
Why not just reduce the height of your first axes a little? See the comments below (I also made some additional improvements).
FigH = figure();
axh = axes(FigH);
axh.Position(4) = axh.Position(4) * .9; % <--- reduce height by 10%
plot(axh, 1:10)
AxesH = axes('Parent', FigH, ...
'Units', 'normalized', ...
'Position', [0, 0, 1, 1], ...
'Visible', 'off', ...
'XLim', [0, 1], ...
'YLim', [0, 1], ...
'NextPlot', 'add');
chr = sprintf('I wanna add a description\nOn top of the plot');
TextH = text(AxesH, 0,1, chr , ...
'HorizontalAlignment', 'left', ...
'VerticalAlignment', 'top');
댓글 수: 2
Adam Danz
2019년 5월 10일
There's no way to create space out of nothing; the space has to come from somewhere. You could make the text one line, you could decrease the font size of the text; but there's no way I can imagine that creates space for your text without changing the axis size.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!