1

Matplotlib の 3D サーフェス プロットでグラフに表示される軸の値を変更するにはどうすればよいですか?

X 軸に 16、32、64、128 の値がありますが、matplotlib は 10、20、30、40 などを表示します。正しく表示するにはどうすればよいですか (正確に 16、32、64、128 の値を意味します)。

ここに画像の説明を入力

以下はコードです:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

plt.title("Just simple text of 3D plot")

X = [   
            [16, 16, 16, 16, 16, 16, 16],
            [32, 32, 32, 32, 32, 32, 32],
            [64, 64, 64, 64, 64, 64, 64],
            [128, 128, 128, 128, 128, 128, 128]
        ]
Y = [   
            [1, 2, 3, 4, 5, 6, 7],
            [1, 2, 3, 4, 5, 6, 7],
            [1, 2, 3, 4, 5, 6, 7],
            [1, 2, 3, 4, 5, 6, 7]
        ]

Z = [
    [550    ,700    ,650    ,550    ,300    ,100    ,5],
    [650    ,760    ,720    ,620    ,350    ,150    ,15],
    [720    ,800    ,780    ,700    ,500    ,250    ,50 ],
    [580    ,690    ,600    ,550    ,250    ,50     ,5  ]
]


ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)

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

ax.view_init(elev=33, azim=155)
plt.savefig("3d_test.png")
4

1 に答える 1

2

私は次のことができると思います:

ax.set_xticks([16,32,64,128])
于 2014-11-08T17:05:10.633 に答える