Code covered by the BSD License  

Highlights from
Fractional position on plots

image thumbnail

Fractional position on plots


Chad Greene


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

function [zcoordinate] = zput(z_position_fraction)
%ZPUT returns z-coordinate of the location on a plot z_position_fraction
%times the full range of the z-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 yput.

zaxisdata = get(gca,'zlim');
zcoordinate = min(zaxisdata)+z_position_fraction*(max(zaxisdata)-min(zaxisdata));

Contact us