Tuesday, December 10, 2019

Functions & Surfaces

function_plotting_py.ipynb
import numpy,pylab; from mpl_toolkits.mplot3d import Axes3D
from matplotlib.lines import Line2D
angle=numpy.linspace(0,2*numpy.pi,64); T1,T2=numpy.meshgrid(angle,angle)
X=numpy.cos(T1)*numpy.sin(T2); Y=numpy.sin(T1)*numpy.sin(T2); Z=numpy.cos(T2)
labels=['$x^2+y^2+z^2=4^2$',
        '$x=3\;cos(t_1)\;sin(t_2)$\n$y=3\;sin(t_1)\;sin(t_2)$\n$z=3\;cos(t_2)$',
        '$\\frac{x^2}{1^2}+\\frac{y^2}{2^2}+\\frac{z^2}{3^2}=1$']
colors=['#3636ff','#ff3636','#ff36ff']
fig=pylab.figure(figsize=(12,12)); ax=fig.add_subplot(111,projection='3d')
ax.plot_surface(4*X,4*Y,4*Z,color=colors[0],alpha=0.1)
ax.plot_surface(3*X,3*Y,3*Z,color=colors[1],alpha=0.1)
ax.plot_surface(1*X,2*Y,3*Z,cmap=pylab.cm.bwr_r,linewidth=1,
                antialiased=True,rstride=1,cstride=1)
fake2Dlines=[Line2D([0],[0],linestyle="none",c=c,marker='o'for c in colors]
ax.legend(fake2Dlines,labels,loc=9,fontsize=15); pylab.show()

Polar Projection

function_plotting_py.ipynb
import numpy,pylab; T=numpy.linspace(start=0,stop=2*numpy.pi,num=200)
XY=numpy.array([[(numpy.cos(12*T)+r)*numpy.cos(T),
                 (numpy.cos(12*T)+r)*numpy.sin(T)] for r in range(3)])
XYP=numpy.array([[T,abs(r+numpy.cos(12*T))] for r in range(3)])
fig=pylab.figure(figsize=(14,7)) 
ax1=fig.add_subplot(121); ax2=fig.add_subplot(122,projection='polar')
colors=['#36ff36','#ff3636','#3636ff']
labels=[u'ϱ = cos 12 θ',u'ϱ = 1 + cos 12 θ',u'ϱ = 2 + cos 12 θ']
[ax1.plot(XY[i][0],XY[i][1],color=colors[i],label=labels[i]) for i in range(3)]
[ax2.plot(XYP[i][0],XYP[i][1],color=colors[i],label=labels[i]) for i in range(3)]
lines,labels=ax1.get_legend_handles_labels()
ax1.legend(lines,labels,bbox_to_anchor=(1,1.15),loc=2)
ax1.grid(); ax1.set_xlim(-3.1,3.1); ax1.set_ylim(-3.1,3.1
ax1.set_xlabel('x'); ax1.set_ylabel('y'); pylab.show()

3D Layer Graphs (Rotating) 2


3D Layer Graphs (Zooming) 2


3D Layer Graphs (Rotating)


3D Layer Graphs (Zooming)


Zooming of Cube Graphs


Rotations of Cube Graphs


Functions with JavaScript & HTML & Plotly

<script type='text/javascript' src='https://cdn.plot.ly/plotly-latest.min.js'></script> was added in the page head.


Rotation of Polygons 2


Rotation of Circles


Rotation of Polygons


Polygons with Increasing Sides, Inscribed in Circles


Rotation of Basic Shapes 3


Rotation of Basic Shapes 2


Rotation of Basic Shapes