matplotlib 绘制函数图像

from curses.panel import bottom_panel, top_panel
from turtle import left, right
import matplotlib.pyplot as plt

itg = 25
x = []
y = []
while itg <= 3000:
  x.append(itg)
  y.append((-1)*itg*itg/(2*45000.0))
  itg = itg + 25

plt.plot(x, y)

plt.title("Square Numbers")
plt.xlabel("x")
plt.ylabel("y")
plt.xlim(0,3000)
plt.ylim(-3000,0)


plt.show()
from curses.panel import bottom_panel, top_panel
from turtle import left, right
import matplotlib.pyplot as plt
import math

itg = 25
x = [0,1,2]
y = [0,0,0]
# while itg <= 3000:
#   x.append(itg)
#   a = 45000+100000
#   y.append((-1)*itg*itg/(2*a))
#   itg = itg + 25


plt.plot(x, y)

x1 = []
y1 = []


cosr = math.cos(math.radians(45))
sinr = math.sin(math.radians(45))
# #anticlockwise
# for i in range(3):
#   x1.append(x[i]*cosr-y[i]*sinr)
#   y1.append(x[i]*sinr+y[i]*cosr)
# plt.plot(x1,y1)

#clockwise
# x = x cosr + y sinr
# y = y cosr - x sinr

x2 = []
y2 = []
for i in range(3):
  x2.append(x[i]*cosr+y[i]*sinr)
  y2.append(y[i]*cosr-x[i]*sinr)
plt.plot(x2,y2)


plt.title("Square Numbers")
plt.xlabel("x")
plt.ylabel("y")
plt.xlim(-5,5)
plt.ylim(-5,5)


plt.show()

你可能感兴趣的:(Shell,matplotlib,python,numpy)