- 武汉近三年空气质量
import matplotlib.pyplot as plt
def plot_forecast():
mo2019 = [125, 80, 76, 62, 65, 46, 44, 50, 58, 56, 77, 93]
mo2020 = [75, 58, 0, 0, 0,23,35,39,47,54,55,99]
mo2021 = [90, 66, 55, 48, 40]
m=range(1,13)
m2021=range(1,6)
plt.plot(m,mo2019,m,mo2020,m2021,mo2021)
plt.legend([2019,2020,2021])
plt.show()
if __name__ == '__main__':
plot_forecast()
- 8大行星和太阳间的引力
'''
quad_function_plot.py
Plot a Quadratic function
'''
import matplotlib.pyplot as plt
import pylab
import sympy
def generate_F_r():
F = []
G = 6.674 * (10 ** -11)
sunWeight = 2.0*(10**30)
# mercury
mercuryWeight = 4.67*(10**24)
mercuryDist=57910 * (10 ** 6)
mercuryForc = G * (sunWeight * mercuryWeight) / (mercuryDist ** 2)
mercuryForc=mercuryForc/1000/1000/10000/10000/10000
F.append(mercuryForc)
# Venus
VenusWeight = 4.8 * (10 ** 24)
VenusDist = 10820 * (10 ** 7)
VenusForc = G * (sunWeight * VenusWeight) / (VenusDist ** 2)
VenusForc = VenusForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append(VenusForc)
# 地球
earthWeight = 5.96*(10**24)
dist1=14710 * (10 ** 7)
force1 = G * (sunWeight * earthWeight) / (dist1 ** 2)
force1=force1/1000/1000/10000/10000/10000
F.append(force1)
# Mars
MarsWeight = 6.4219 * (10 ** 23)
MarsDist = 22800* (10 ** 7)
MarsForc = G * (sunWeight * MarsWeight) / (MarsDist ** 2)
MarsForc = MarsForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append(MarsForc)
# Jupiter
JupiterWeight = 1.8982 * (10 ** 27)
JupiterDist = 77854.7200* (10 ** 7)
JupiterForc = G * (sunWeight * JupiterWeight) / ( JupiterDist ** 2)
JupiterForc = JupiterForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append( JupiterForc)
# Saturn
SaturnWeight = 5.6 * (10 ** 26)
SaturnDist = 14294 * (10 ** 8)
SaturnForc = G * (sunWeight * SaturnWeight) / ( SaturnDist ** 2)
SaturnForc = SaturnForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append( SaturnForc)
# Uranus
UranusWeight = 8.681 * (10 ** 25)
UranusDist = 28710 * (10 ** 8)
UranusForc = G * (sunWeight * UranusWeight) / ( UranusDist ** 2)
UranusForc = UranusForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append( UranusForc)
# Neptune
NeptuneWeight = 1.0241 * (10 ** 26)
NeptuneDist = 45040 * (10 ** 8)
NeptuneForc = G * (sunWeight * NeptuneWeight) / ( NeptuneDist ** 2)
NeptuneForc = NeptuneForc / 1000 / 1000 / 10000 / 10000 / 10000
F.append( NeptuneForc)
plt.bar(range(len(F)), F)
plt.show()
if __name__ == '__main__':
generate_F_r()
孩子能跳多远:
import matplotlib.pyplot as plt
import pylab
import math
def draw_graph(x, y):
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title('long jimp?')
plt.axis(ymax=2)
def frange(start, final, increment):
numbers = []
while start < final:
numbers.append(start)
start = start + increment;
return numbers;
def draw_trajectory (u, theta):
theta=math.radians(theta)
g=9.8
t_flight=2*u*math.sin(theta)/g
intervals=frange(0,t_flight,0.001)
x=[]
y=[]
for t in intervals:
x.append(u*math.cos(theta)*t)
y.append(u*math.sin(theta)*t-0.5*g*t*t)
draw_graph(x, y)
if __name__ == '__main__':
draw_trajectory(5, 20)
plt.show()
你在月亮上能跳多远:
import matplotlib.pyplot as plt
import pylab
import math
def draw_graph(x, y):
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title('long jimp?')
plt.axis(ymax=2)
def frange(start, final, increment):
numbers = []
while start < final:
numbers.append(start)
start = start + increment;
return numbers;
def draw_trajectory (u, theta,g):
theta=math.radians(theta)
# g=9.8
t_flight=2*u*math.sin(theta)/g
intervals=frange(0,t_flight,0.001)
x=[]
y=[]
for t in intervals:
x.append(u*math.cos(theta)*t)
y.append(u*math.sin(theta)*t-0.5*g*t*t)
draw_graph(x, y)
if __name__ == '__main__':
draw_trajectory(5,20,9.8)
draw_trajectory(5, 20, 1.63)
plt.show()