Matplotlib를 사용하여 축을 숨기지만 축 레이블을 3D 플롯으로 유지하려면 다음 단계를 수행할 수 있습니다. -
- 그림 크기를 설정하고 서브플롯 사이 및 주변 여백을 조정합니다.
- 새 그림을 만들거나 기존 그림을 활성화합니다.
- '~.axes.Axes 추가 ' 하위 플롯 배열의 일부로 그림에.
- numpy를 사용하여 x, y, z, dx, dy 및 dz 데이터 포인트 생성
- bar3d() 사용 3D 막대를 그리는 방법입니다.
- 축을 숨기려면 좌표축 색상과 동일한 색상 튜플을 초기화합니다.
- x, y, z축 평면 색상 속성을 색상 튜플과 동일하게 설정합니다.
- x, y, z축 선 색상 속성을 색상 튜플과 동일하게 설정합니다.
- x, y 및 z축에 빈 눈금을 설정합니다.
- x, y 및 z축 레이블을 설정합니다.
- 그림을 표시하려면 show()를 사용하세요. 방법.
예
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [5, 6, 7, 8, 2, 5, 6, 3, 7, 2]
z = np.zeros(10)
dx = np.ones(10)
dy = np.ones(10)
dz = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ax.bar3d(x, y, z, dx, dy, dz, color="green")
color_tuple = (1.0, 1.0, 1.0, 0.0)
ax.w_xaxis.set_pane_color(color_tuple)
ax.w_yaxis.set_pane_color(color_tuple)
ax.w_zaxis.set_pane_color(color_tuple)
ax.w_xaxis.line.set_color(color_tuple)
ax.w_yaxis.line.set_color(color_tuple)
ax.w_zaxis.line.set_color(color_tuple)
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
ax.set_xlabel('X-Axis')
ax.set_ylabel('Y-Axis')
ax.set_zlabel('Z-Axis')
plt.show() 출력
