Code covered by the BSD License  

Highlights from
Fractional position on plots

image thumbnail

Fractional position on plots


Chad Greene (view profile)


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

function [ycoordinate] = yput(y_position_fraction)
%YPUT returns y-coordinate of the location on a plot y_position_fraction
%times the full range of the y-axis. 
% Chad A. Greene 2012.
% 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
% See also xput and zput.

yaxisdata = get(gca,'ylim');
ycoordinate = min(yaxisdata)+y_position_fraction*(max(yaxisdata)-min(yaxisdata));

Contact us