[英]Changing axis options for Polar Plots in Matplotlib/Python
[英]Polar projection with 3 axis in matplotlib/plotly/bokeh for Python? (Hive plots)
極坐標投影是否可以調整3軸? 我想可能是3D散點圖傾斜到2D上,所以它像這樣排列?
我最近發現了有關Hive Plots的信息 ,我想嘗試編寫一個代碼,這樣我就可以在美學方面有更多的自由范圍,使其看起來更像這些家伙 。 我開始嘗試制作一個,但我想到的唯一方法就是使用這樣的極坐標。
我的問題: 有沒有辦法在matplotlib,plotly或bokeh中獲取3軸極坐標? 或者如果沒有, 是否有一種方法可以修復3D圖以具有這種類型的結構?
fig = plt.figure(figsize=(10,10))
ax = plt.subplot(111, polar=True)
ax.plot(2*[np.pi/2], [0,1], color="black", linewidth=3)
ax.plot(2*[5*np.pi/4], [0,1], color="black", linewidth=3)
ax.plot(2*[7*np.pi/4], [0,1], color="black", linewidth=3)
也許是一個開始,但是我會檢查一下matplotlib 2.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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.