필터 지우기
필터 지우기

anyway to add text with given location at a 'pixel' based figure

조회 수: 9 (최근 30일)
Yu Li
Yu Li 2019년 1월 18일
댓글: Walter Roberson 2019년 1월 19일
is there anyway to add text with given location at a 'pixel' based figure?
in the link below: https://www.mathworks.com/help/matlab/creating_plots/add-text-to-specific-points-on-graph.html it requires the position of a given point. but in my situation, I want to add the text at a given place of a pixel based figure.
Bests,
Yu

채택된 답변

Kevin Phung
Kevin Phung 2019년 1월 18일
편집: Kevin Phung 2019년 1월 18일
yep!
just do something like:
text1 = uicontrol('Style','text','units','pixels',...
'position',[],'String','Hello')
Just call out the handle text1 and you can see what other properties of the text box you can adjust (color, fontsize,tag, etc..)
  댓글 수: 5
Kevin Phung
Kevin Phung 2019년 1월 19일
Ahh I see, usually, to center a text with respect to its borders, I add an extra element to the string, so
text1 = uicontrol('Style','text','units','pixels',...
'position',[],'String',{'','Experiment'})
should center the word 'Experiment' in the box. Not the most elegant solution.. but I hope the result is what yo uare looking for.
Yu Li
Yu Li 2019년 1월 19일
I have slightly adjust the position to achieve the desired disply. thank you so much and wish you a wonderful weekend!
Bests,
Yu

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 1월 19일
text() permits you to specify horizontal and vertical alignment, and permits you to specify Position and to specify Units . So you can specify the location in Units pixels and you can control how the text aligns relative to that location.
  댓글 수: 2
Yu Li
Yu Li 2019년 1월 19일
Thank you Walter, however, unfortunately, there is no vertical alligment selection....
https://www.mathworks.com/matlabcentral/answers/328604-how-do-i-get-my-text-to-center-vertically-in-a-uicontrol-textbox
Walter Roberson
Walter Roberson 2019년 1월 19일
I would not use uicontrol for this purpose . text() within an axes, annotation() for outside an axes.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by