In matplotlib
, what is the best way to plot a family of curves which is a solution to a differential equation. How can I plot for example,
and to overlay family of orthogonal trajectories over this family of curves
Finally I want to be able to produce a figure similar to the following
I am aware of contour plots of implicit functions, but how are they related to the constant C in the above equations. I could produce following figure based on the suggestion, But I can't to seem to have the contour labels on the overlaid parabolas.
CODE:
import matplotlib.pyplot as plt
from numpy import arange, meshgrid
delta = 0.025
x_range = arange(-20.0, 20.0, delta)
y_range = arange(-20.0, 20.0, delta)
X, Y = meshgrid(x_range,y_range)
fig=plt.figure()
ax=fig.add_subplot(111)
ax.set_xlim(xmin=-6, xmax=6)
ax.set_ylim(ymin=-4, ymax=4)
ax.axhline(y=0, color='k',linewidth=1)
ax.axvline(x=0, color='k',linewidth=1)
# F is one side of the equation, G is the other
F = (X**2)/2.0+(Y**2)
colrs_tuple=('k','c','c','k')
#C = range(6,14,3)
C = (2,6,9,12)
#print(type(C))
CS = plt.contour(X, Y, F, C, colors=colrs_tuple)
labels = plt.clabel(CS)
xy = [t.get_position() for t in labels]
print(xy)
F=Y
G=X**2
C = (-5,-3,-1,1,3,5)
##for c1 in C:
## CS=plt.contour(X, Y, F/G- c1,[0], colors='c',linestyles='dashed')
## labels = plt.clabel(CS)
## xy = [t.get_position() for t in labels]
## print(xy)
##plt.show()
CS1=plt.contour(X, Y, F/G,levels=(-15,-3,-1,-0.5,0.5,1,3,15), colors='c',linestyles='dashed')
labels1 = plt.clabel(CS1)
plt.show()