Problems about setting the location of text in a figure

2 次查看(过去 30 天)
Hi everybody, i have a box with two axes inside (one on the left, one on the righ), and i want to put some text describing the axes (which contain two coloured amplitude maps). My problem is that i set the 'Position' property trying to make every text linked with one of the axes, like this:
possx=get(ax1,'pos'); %Position of left axes
posdx=get(ax2,'pos'); %Position of right axes
text('String','Sx','Fontsize',12,'Position',[possx(1) possx(2)+0.5 0]) %text linked to the left axes
text('String','Dx','Fontsize',12,'Position',[posdx(1) posdx(2)+0.5 0]) %text linked to the right axes
The problem is that this instructions seems to be useless, the text is ALWAYS sticked to the second axes (which is the one on the right and the last created in the script), whether i write the code for the position or not. Why it doesn't work? It seems to be really skipped by the execution.

回答(1 个)

Megha Mukim
Megha Mukim 2017-2-3
编辑:Megha Mukim 2017-2-3
I recommend going through the documentation at the links below:
There are examples that illustrate how to put the 'Text' objects at a particular point and specific axes. You might want to try something similar to:
text(ax1,'Sx','Fontsize',12,'Position',[possx(1) possx(2)+0.5 0])
text(ax2,'Dx','Fontsize',12,'Position',[posdx(1) posdx(2)+0.5 0])
Also, there is no property called 'String' explicitly. It just refers to the String to be displayed on the figure.
Please note: If you do not specify an axes object, then text uses the current axes. Hence, this might be the reason that your text object always appear on the second axes.

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by