问题
I would like to 3D plot the surface of a data 2d array with dimension [50,250]. Two of the axes (x, z
) should be in logarithmic scale. Here's a MWE:
import numpy as np
xx = np.asanyarray([np.ones([250])*(m+1) for m in range(50)])
yy = np.asanyarray([range(250) for m in range(50)])
zz = np.asanyarray([np.sqrt(np.arange(250)*m) for m in range(50)])
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(xx, yy, zz, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.yaxis.set_scale('log')
All other answers I found indicate that this last line should do the trick. Instead, it raises the following AttributeError: 'YAxis' object has no attribute 'set_scale'
I don't get why it does so. I have the latest version of matplotlib installed in my Mac Osx 10.9.7 (that is 2.1.0).
Can anybody assist me on this one?
来源:https://stackoverflow.com/questions/46891692/cant-set-axis-scale-to-logarithmic-in-3d-plot-in-matplotlib