Code covered by the BSD License  

Highlights from
Fractional position on plots

image thumbnail

Fractional position on plots

by

 

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

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

xaxisdata = get(gca,'xlim');
xcoordinate = min(xaxisdata)+x_position_fraction*(max(xaxisdata)-min(xaxisdata));
end

Contact us