-1
私はpython 3.4で作業しています。私は2D配列(11x13)から単純なサーフェスをプロットしようとしていますが、カラーマップが正しく卒業していません。小さな範囲しかありませんが、プロットにストライプがある間にカラーバーが妥当に見えます。どのようなカラーマップを使用しても問題ないようですが、同等の結果が得られます。サーフェスプロットは卒業色ではありません
別の投稿から、私はrstride &パラメータを使用しようとしましたが、表面全体がピンク(このマップで)になっています。
提案がありますか?私はmplot3dのチュートリアルの例の1つからコードを変更しました - 基本的にはX、Y、Z、軸の限界を置き換え、異なるカラーマップを試しました。同様の質問でこのスレッドを見つけた誰のために
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
# Make data.
X = np.arange(0,550,50)
Y = np.arange(-12,1,1)
X, Y = np.meshgrid(X, Y)
# Array calculated with a process in excel...I'll learn to python it later.
Z = np.array([[0,0,0,0,0,0,0,0,9.318546297,9.32278014,9.324432509],
[0,0,0,0,0,0,9.270465014,9.281098393,9.287418343,9.291620087,9.293257704],
[0,0,0,9.183895053,9.20724459,9.226419172,9.239450746,9.25002849,9.257383697,9.261920422,9.263632585],
[9,9.086332608,9.126397936,9.153091476,9.176369804,9.195477721,9.210108238,9.22128034,9.229169896,9.233975347,9.235758722],
[9,9.0556775,9.095671635,9.125345711,9.149164982,9.168378335,9.183464661,9.194945002,9.203079816,9.208024884,9.209844315],
[9,9.040637647,9.075058225,9.10310915,9.126085,9.144796641,9.15970021,9.171125191,9.179264934,9.184223248,9.186039585],
[9,9.031750626,9.060617885,9.085619791,9.106813693,9.12444679,9.13872781,9.149807723,9.157769849,9.162644172,9.164426795],
[9,9.025687536,9.049859786,9.071632721,9.09067842,9.106911657,9.120316269,9.130877982,9.138559174,9.14329971,9.145034568],
[9,9.021085904,9.041333766,9.060092969,9.076965929,9.091711302,9.104158214,9.114155647,9.121547513,9.126169075,9.127867857],
[9,9.017274923,9.034147314,9.050188629,9.065030255,9.07836292,9.08991453,9.099425441,9.106628029,9.111235402,9.112955947],
[9,9.01382656,9.027663537,9.041265696,9.054295453,9.066400007,9.077233581,9.086451516,9.09368943,9.098527457,9.100440892],
[9,9.010336943,9.021310255,9.032733661,9.044224745,9.055367181,9.065750219,9.074968252,9.082599449,9.088144367,9.090799207],
[9,9.00619218,9.014431776,9.023994936,9.034293996,9.04481216,9.055077078,9.064646767,9.073106766,9.080108346,9.085588416]])
# replacing the zeroes with NaN
for i in range(np.shape(Z)[0]):
for j in range(np.shape(Z)[1]):
if Z[i,j] == 0:
Z[i,j] = float('nan')
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.cool,
linewidth=0, antialiased=False)
# Customize the z axis.
ax.set_zlim(9, 9.5)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
これはPythonでですか?あなたのコードを見せることができますか? –
完了。私はそれらの数字をすべて貼り付けたくないと思っていました...表面の「形」は正しいように見えますが、色は一致しません。 – MNoteboom