#python #matplotlib #scatter
#python #matplotlib #scatter
Вопрос:
Я пытаюсь использовать 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)
Комментарии:
1. Вы пропускаете закрытие
)
в конце предыдущей строки
Ответ №1:
Проверьте вторую последнюю строку sphere = 4 *(np.pi * planet_radius ** 2.0
Скобки отсутствуют в конце.
Комментарии:
1. Я изменил свой код, чтобы он выглядел так, как сейчас, но теперь у меня проблема с t = dt. где ошибка: недопустимый синтаксис