I'm relatively new to matplotlib so I need some help. I'm trying to make a
direction field plot for visualzing solutions to differential eqs. My first
attempt at a simple plot came out all right but I can't figure out why the
plotted lines are not the same length. The block of code that does all of
the work is...
for x in ax1.xaxis.iter_ticks(): #Iterate
over xticks
for y in ax1.yaxis.iter_ticks(): #iterate
over yticks
# Solve for local slope at point to be evaluated (dy/dx)
yp = 9.8  ((np.float(y[1]))/4) #yp = y` as
in dy/dx
# Plot line based on slope
cpx = np.float(x[1]) #cpx = xcoord of line center,
convert xtick value to float
cpy = np.float(y[1]) #cpy = ycoord of line center,
covnert ytick value to float
a = np.arctan(yp) #a = angle between line and
horizontal
px = np.cos(a)*(L/2) #px = x offset from line center to
end
py = np.sin(a)*(L/2) #py = y offset from line center
to end
tpx = cpx + px #tpx = xcoord of right hand
end of line
tpy = cpy + py #tpy = ycoord of right hand
end of line
bpx = cpx  px #bpx = xcoord of left hand end
of line
bpy = cpy  py #bpy = ycoord of left hand end
of line
Length = np.sqrt(((tpxbpx)**2)+((tpybpy)**2))
#just a quick check of the line length accoring to the coordinates of
the ends
ax1.plot([bpx, tpx], [bpy, tpy], color='black', linewidth=0.75)
As you can see in the attached figure (see below), the lines seem to plot in
the right locations and right angles but the lengths are not constant (not
intended  seem to be twice as long near the middle of the chart). Am I
missing something obvious? Why are the lines near the center of the chart
longer? Thanks in advance for any help provided.
Ryan
http://old.nabble.com/file/p28859981/img1.png

View this message in context: http://old.nabble.com/Needhelpwithdirectionfieldplottp28859981p28859981.html
Sent from the matplotlib  users mailing list archive at Nabble.com.
