[英]Gridlines Above 3D Scatter Plot in matplotlib
使用matplotlib制作3D散點圖時,我似乎無法控制軸是在圖上方還是下方。 例如,如果ax1.elev <0,則以下代碼將始終在圖上方具有x和y軸
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
fig = plt.figure('Test')
X = np.random.rand(1,100)
Y = np.random.rand(1,100)
Z = np.random.rand(1,100)
ax1 = fig.add_subplot(111, projection = '3d')
ax1.scatter(X,Y,Z)
ax1.view_init(-10,45)
即使ax1.elev <0,是否可以強制x和y軸以及網格線和平面低於繪圖?
我以此問題的代碼為例(感謝crayzeewulf )。 除z軸外,我們對x軸和y軸進行測量
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
fig = plt.figure('Test')
X = np.random.rand(1,100)
Y = np.random.rand(1,100)*10
Z = np.random.rand(1,100)
ax1 = fig.add_subplot(111, projection = '3d')
ax1.scatter(X,Y,Z)
ax1.view_init(-10,45)
tmp_planes = ax1.zaxis._PLANES
ax1.xaxis._PLANES = ( tmp_planes[3], tmp_planes[2],
tmp_planes[1], tmp_planes[0],
tmp_planes[5], tmp_planes[4])
ax1.yaxis._PLANES = ( tmp_planes[3], tmp_planes[2],
tmp_planes[1], tmp_planes[0],
tmp_planes[5], tmp_planes[4])
view_1 = (25, -135)
view_2 = (-10, 45)
init_view = view_2
ax1.view_init(*init_view)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.