简体   繁体   English

Jupyter标记z轴时出现名称错误

[英]Jupyter labelling z-axis gives nameerror

I have the following block of code to produce a 3D plot of sets of data: 我有以下代码块来生成数据集的3D图:

figure(figsize=(20, 15))
ax = gca(projection="3d")
ax.plot_wireframe(X, Y, Z)
xlabel("x")
ylabel("y")
zlabel("z")
show()

However, an error is made when labelling the z-axis: 但是,标记z轴时会出错:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-34-987e9d2dec12> in <module>()
      4 xlabel("x")
      5 ylabel("y")
----> 6 zlabel("z")
      7 show()

NameError: name 'zlabel' is not defined

I defined the z-axis using the following code earlier: 我之前使用以下代码定义了z轴:

def z(x, y):

    b = 0.5**(x**2+y**2)
    return sin(b)

Z_data = z(X, Y)

I can't see what the problem appears to be. 我看不出问题出在哪里。 What is the issue? 有什么问题

As I am calling ax = gca() it seemed appropriate to use the ax method. 当我调用ax = gca()时,使用ax方法似乎合适。

Hence, discovering on google that ax.set_zlabel('z') also managed to do the job gave me the solution I needed. 因此,在Google上发现ax.set_zlabel('z')也成功完成了这项工作,这给了我所需的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM