gpt4 book ai didi

python - ax.scatter() 语法无效?

转载 作者:行者123 更新时间:2023-12-01 02:32:10 31 4
gpt4 key购买 nike

我已成功绘制了两个图表,但当我绘制第三个图表时,出现无效语法错误。我是否遗漏了一些非常明显的东西?

x=df['time']
d=df['dist']
x2=df2['time']
d2=df2['dist']
p2=df2['pressure']
mx2=df2['magx']

#plot 1
fig, ax = plt.subplots(2, figsize=(6,6))
ax[0].scatter(x,d,s=10)
ax[1].scatter(x2, d2, s=10)

#plot 2
fig, ax = plt.subplots(1, figsize=(6,6))
ax.scatter(x2,p2,s=10)

#plot 3
fig, ax = plt.subplots(1, figsize=(6,6)
ax.scatter(x2, mx2, s=10)

fig.show()

当我注释掉图 3 时,其他图就很好了。当我尝试绘制图 3 时,出现以下错误:

ax.scatter(x2, mx2, s=10) 
SyntaxError: invalid syntax

最佳答案

#plot 3
fig, ax = plt.subplots(1, figsize=(6,6))

关闭括号:)

关于python - ax.scatter() 语法无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46680148/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com