python三维图形编程极坐标_Python的matplotlib/plotly/bokeh中的三轴极坐标投影?(蜂巢图)...

也许是个开始,但我会检查matplotlib2.0看看3D是否更好import numpy as np

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

def Lin3dSeg(a,b):

'''

if a, b are spherical coordinate vector tuples, then it

returns list of spherical coordinate points of a linear in r, theta, phi

3D spiral segment connecting them

'''

return [np.linspace(start, stop) for start, stop in zip(a,b)]

def Sphere2Cart(sphere_pt): # no particular convention, just thrown together

x = sphere_pt[0] * np.sin(sphere_pt[1])

y = sphere_pt[0] * np.cos(sphere_pt[1])

z = sphere_pt[0] * np.cos(sphere_pt[2])

return (x, y, z)

def SphereSegCarts(seg):

return [Sphere2Cart(pt) for pt in zip(*Lin3dSeg(*seg))]

seg_a =((10, 0, 0),(5, np.pi/2, 0))

seg_b =((10, np.pi/2, 0),(1, 0, np.pi/2))

seg_c =((3, 0, np.pi/2),(10, np.pi/2, np.pi/2))

fig = plt.figure()

ax = fig.add_subplot(111, projection='3d')

ax.view_init(elev=45, azim=45)

ax.plot(*zip(*SphereSegCarts(seg_a)), c='r')

ax.plot(*zip(*SphereSegCarts(seg_b)), c='g')

ax.plot(*zip(*SphereSegCarts(seg_c)), c='b')

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值