繁体   English   中英

我正在尝试使用 pyplot.scatter() 但我收到无效的语法错误

[英]I'm trying to use pyplot.scatter() but I'm getting an invalid syntax error

我正在尝试使用 pyplot.scatter() 但我收到以下错误:

 plt.scatter(y=temperature_planet,x=t,s=2, color="red")
   ^
 SyntaxError: invalid syntax

您可以看到问题出在代码的最后一行。 我不确定发生了什么

我的代码:

import numpy as np
import matplotlib.pyplot as plt 
import time
import decimal

t = 0
temperature_planet = 200
temperature_atmosphere = 250

epsilon = decimal.Decimal(0.25)
dt = 60*10
heat_capacity = decimal.Decimal(1E5)
insolation = decimal.Decimal(1370)
sigma = decimal.Decimal(5.67E-8)
planet_radius = decimal.Decimal(6.4E6)

circle = decimal.Decimal(np.pi)*planet_radius**decimal.Decimal(2.0)
sphere = 4*decimal.Decimal(np.pi)*planet_radius**decimal.Decimal(2.0)


plt.scatter(y=temperature_planet,x=t,s=2, color="red")
plt.ion()
plt.xlabel("Time (S)")
plt.ylabel("Temperature (K)")
plt.legend(loc='upper left')
plt.show()

print(temperature_planet)
while True:
   temperature_planet += dt*(circle*insolation + sphere* epsilon*sigma* 
   temperature_atmosphere**decimal.Decimal(4.0) - 
   sphere*sigma*temperature_planet**decimal.Decimal(4.0)/heat_capacity
   t += dt
   plt.scatter(y=temperature_planet,x=t)
   plt.pause(0.005)
   time.sleep(0.05)

检查倒数第二行 sphere = 4*(np.pi*planet_radius**2.0

最后缺少括号。

暂无
暂无

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

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