How to write a 'text' at the end of another one
3 ビュー (過去 30 日間)
古いコメントを表示
Hi everybody and thanks in advance for taking a look at my question.
My problem is simple: I want a 'text' in a MATLAB 'figure' to be show at a location "relative to a second text". I need to plot 2 things and I'd like to have the second 'text' to be shown at the end of the first one. Forgive me for my bad English hope I was able to explain the problem. Thanks, Alessandro. PS:**whatdoiputhere** should be the length of 'Moto del CIR' translated in whatever unit MATLAB uses in figures and "normalized" so that I have one text just after the other one. Here is my actual problem:
text(0,1.0,['Moto del CIR.'],'color',[0 0 1],'units','normalized','VerticalAlignment','bottom');
plot(xg(i),yg(i),'.r') ; plot(xg(1:i),yg(1:i),'r') ;
text(**whatdoiputhere?**,1.0,['Moto del Baricentro.'],'color',[1 0 0],'units','normalized','VerticalAlignment','bottom');
0 件のコメント
回答 (2 件)
Salaheddin Hosseinzadeh
2015 年 6 月 7 日
Hi Alessandro,
You have to use text, see matlab help for text please
text(Xposition,Yposition,'Your String!');
To plot relative to the first position just add a value to x and y positions
dX = 2;
dY = 4; % for example
text(Xposition+dX, Yposition+dY,'your new string')
Something like this should solve your problem
0 件のコメント
Jan
2015 年 6 月 7 日
You can obtain the extent of the first text tolocate the correct position of the second text:
TextH = text(0, 1.0, 'Moto del CIR.', ...
'color', [0, 0, 1], ...
'units', 'normalized', 'VerticalAlignment', 'bottom');
Ext = get(TextH, 'Extent');
text(Ext(3), 1.0, 'Moto del Baricentro.', ...
'color', [1, 0, 0], ...
'units', 'normalized', 'VerticalAlignment','bottom');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!