gpt4 book ai didi

python - 从 matplotlib 3D Pane 中删除边框

转载 作者:行者123 更新时间:2023-12-04 15:35:41 24 4
gpt4 key购买 nike

我想按如下所述从我的 3D 场景中删除边框。知道怎么做吗?

enter image description here

这里是生成当前场景的代码:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Create figure
plt.style.use('dark_background') # Dark theme
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Make panes transparent
ax.xaxis.pane.fill = False # Left pane
ax.yaxis.pane.fill = False # Right pane

# Remove grid lines
ax.grid(False)

# Remove tick labels
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_zticklabels([])

# Print chart
file_path = 'charts/3d.png'
fig.savefig(file_path, bbox_inches='tight', pad_inches=0.05, transparent=True)

最佳答案

我通常将书脊和 Pane 的 alpha channel 设置为 0,最后我删除刻度线:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Create figure
plt.style.use('dark_background') # Dark theme
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Make panes transparent
ax.xaxis.pane.fill = False # Left pane
ax.yaxis.pane.fill = False # Right pane

# Remove grid lines
ax.grid(False)

# Remove tick labels
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_zticklabels([])

# Transparent spines
ax.w_xaxis.line.set_color((1.0, 1.0, 1.0, 0.0))
ax.w_yaxis.line.set_color((1.0, 1.0, 1.0, 0.0))
ax.w_zaxis.line.set_color((1.0, 1.0, 1.0, 0.0))

# Transparent panes
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))

# No ticks
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])

关于python - 从 matplotlib 3D Pane 中删除边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59857203/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com