function_plotting_py.ipynb
from mpl_toolkits.mplot3d import Axes3D; from matplotlib.lines import Line2D
import numpy,pylab; X=numpy.linspace(-3,3,128); X,Z=numpy.meshgrid(X,X)
def f1(x,z): return 2*x
def f2(x,z): return 5
Y=[f1(X,Z),-f1(X,Z),f2(X,Z),-f2(X,Z)]
colors=['#ff36ff','#ff3636']
labels=['$\\frac{x^2}{1^2}=\\frac{y^2}{2^2}$','$y^2=5^2$']
fig=pylab.figure(figsize=(12,12)); ax=fig.add_subplot(111,projection='3d')
[ax.plot_wireframe(X,y,Z,color=colors[0],alpha=0.3) for y in Y[:2]]
[ax.plot_surface(X,y,Z,cmap=pylab.cm.bwr,linewidth=1,
antialiased=True,rstride=3,cstride=3) for y in Y[2:]]
fake2Dlines=[Line2D([0],[0],linestyle="none",c=c,marker='o') for c in colors]
ax.legend(fake2Dlines,labels,loc=9,fontsize=15); pylab.show()
No comments:
Post a Comment