2017-08-22 16 views
0

これはGoogleスプレッドシートを使用して3Dで行ったチャートです。matplotlibでログスケールを使用した場合のティックの間隔を設定する

enter image description here

私はmatplotlibの上で同じスケールを達成したいが、3Dサーフェスを使用。 問題は、logscaleのティックが、通常のスケールであれば、 "should be"に配置されていることです。ここで enter image description here

私のコードです:

X, Y = np.meshgrid(numrec, numtreino) 

Z = (numerador/(((rec[0])+(treino[0]*60))/((rec[1])+(treino[1]*60))))*X 

# Plot the surface. 
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, 
         linewidth=2, antialiased=True, alpha=0.8) 

ax.set_xscale('symlog') 
ax.set_yscale('symlog') 
ax.invert_xaxis() 


# Add a color bar which maps values to colors. 
fig.colorbar(surf, shrink=0.5, aspect=5) 

plt.show() 
+0

私は[この問題は](https://github.com/m atplotlib/matplotlib/issues/209)が問題をカバーしています。いくつかの回避策があります。それらのいずれかを実装する際に問題がある場合は、未知の変数を持つコードをそのまま使用するのではなく、問題の[mcve]を提供してください。 – ImportanceOfBeingErnest

答えて

0

ImportanceOfBeingErnestで指摘したように、matplotlibのバグのようです。

3D散布図を作成するときにログスケールを有効にすると、何も作成されず、プログラムがクラッシュします。 ax.set_xscale('log')の代わりにax.set_xscale('symlog')を使用してください。私が追加したティックを設定するには

Z = (numerador/(((rec[0])+(treino[0]*60))/((rec[1])+(treino[1]*60))))*X 

X = np.log10(X) 
Y = np.log10(Y) 
# Plot the surface. 

:に

Z = (numerador/(((rec[0])+(treino[0]*60))/((rec[1])+(treino[1]*60))))*X 

# Plot the surface. 

:私が変更したスケーリングの問題を解決するには

zticks = [ 1e3, 1e2, 1e1] 
ax.set_xticks(np.log10(zticks)) 
ax.set_xticklabels(zticks) 

enter image description here

関連する問題