1

3D matplotlib 散布図で特定のグリッド線の色/太さを変更しようとしています。この場合、-30 z 軸のグリッド線を黒、太字、または太くして、他のグリッド線の中で目立つようにします。以下は、mplot3d 散布図チュートリアルから見た基本的なコードです。

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

def randrange(n, vmin, vmax):
    return (vmax-vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zl, zh)
    scat = ax.scatter(xs, ys, zs, c=c, marker=m)

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()

私は次のことを試しました:

y_min, y_max = scat.axes.get_ylim()
scat.axes.set_ylim([y_min,y_max])
x_min, x_max = scat.axes.get_xlim()
scat.axes.set_xlim([x_min,x_max])

plt.plot([0.0,0.0], [y_min,y_max], 'k-', lw=2)
plt.plot([x_min,x_max], [0.0225,0.0225], 'k-', lw=2)

ax.w_zaxis._axinfo.update({ztick[2] : {'color': (0, 0, 0, 1)}})

助けてくれてありがとう。

4

1 に答える 1