Problems about setting the location of text in a figure
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Megha Mukim
on 3 Feb 2017
Edited: Megha Mukim
on 3 Feb 2017
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.
0 Comments
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!