我想在三维线框图中添加一些文本。我从matplotlib库中this example的代码开始。从Axes
文档中,我发现了一个^{self
)。我将示例修改如下:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Grab some test data.
X, Y, Z = axes3d.get_test_data(0.05)
# Plot a basic wireframe.
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
ax.text(0, 0, "I'm here")
plt.show()
当我运行这个代码时
TypeError: text() missing 1 required positional argument: 's'
我该怎么解决这个问题?我做错什么了?你知道吗
在本例中,您处理的不是^{} 对象,而是^{} 对象。因此,您需要为其^{} 方法提供三个坐标数,而不仅仅是2。你知道吗
或者您也可以使用^{} 方法,它只需要两个坐标数输入参数。你知道吗
help(ax.text)
给出了正确的文档:所以你需要3个位置坐标,没有
self
。你知道吗相关问题 更多 >
编程相关推荐