Code covered by the BSD License

### Highlights from Fractional position on plots

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 8.17 KB File ID: #38110

# Fractional position on plots

Position text or data relative to the frame of a plot, not necessarily relative to the data.

File Information
Description

Functions xput, yput, and zput return the respective x, y, or z coordinate of a given fraction of the full x, y, or z range of a plot. These are useful if you have several plots with different data ranges, but you want text or a marker to appear in the same position relative to the frame of each plot. Input argument is simply the fractional linear dimension from 0 to 1.

EXAMPLE:
x = -40:120;
y = x + 10*sin(x);
plot(x,y); hold on
plot(xput(.2),yput(.4),'rp','markersize',15)
text(xput(.1),yput(.9),'this is an example','fontsize',14)
text(xput(.6),yput(.25),'another example!','fontsize',16)
box off

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)

Jan, that's a great suggestion! I was not aware of the normalized units option. You're right, it's a much better solution than the functions here. Thanks for the tip!

Comment only
11 Sep 2012 Jan Simon

### Jan Simon (view profile)

I suggest 'normalized' units for TEXT():
text(0.6, 0.25,'another example!','fontsize',16, 'Units', 'normalized')
Then even zooming does not change the position, e.g. when the resolution is changed temporarily for printing.

But for PLOT() this suggestion will not work. There are good reasons not to use units other than 'data' for line plots.

Comment only