I want to insert some arrows into a plot of some exponential distributions:
import pylab as pl
import numpy as np
def gauss2d(x,sigma):
return (1/np.sqrt(2*np.pi*sigma ))*np.exp(-1/2*(x/sigma)**2 )
def draw_arrow(zero, sigma, function):
startx = zero
print startx,function(sigma, sigma)
arr = pl.Arrow(startx,function(startx+sigma, sigma), sigma,0,fc="k",ec="k")
ax = pl.gca()
ax.add_patch(arr)
def plot_gauss2d():
x = np.mgrid[115:135:100j]
#x=np.array(zip(range(5)),dtype=float)
sigma = 1
off=1.0
pl.plot(x,gauss2d(x-126.21,3.56), 'b-')
draw_arrow(126.21, 3.56, gauss2d)
pl.plot(x,gauss2d(x-126.71,4.57), 'b-')
pl.plot(x,gauss2d(x-120.64,3.5), 'b-')
pl.ylabel('frequency')
pl.xlabel('ppm of N')
pl.title
pl.show()
def main():
plot_gauss2d()
if __name__ == "__main__":
main()

Somehow I can’t seem to get the arrow right. What I essentially would like to have is something like this:

what I simply cannot figure out is how to set the arrow straight to where I want it to be. It should mark the point of the standard deviation in the correct height. The whole thing should of course produce multiple exponential curves.
The problem with arrow is that it uses the
figurecoordinate as compared to thedatacoordinates. Hence, as @Paul have suggested, you can use annotate, as