15-1:数字的三次方称其立方,绘制一个图形,显示前5个整数的立方,在绘制一个显示前5000个整数的立方值
#-*-coding:GBK-*-
#-*-coding:utf-8-*-
import matplotlib.pyplot as plt
x=[1,2,3,4,5]
y=[1,8,27,64,125]
plt.scatter(x,y,s=5)
plt.title('cube numbers',fontsize=24)
plt.xlabel("value",fontsize=10)
plt.ylabel("cube",fontsize=10)
plt.tick_params(axis='both',which='major',labelsize=14)
plt.show()
#-*-coding:GBK-*-
#-*-coding:utf-8-*-
import matplotlib.pyplot as plt
x=list(range(1,5001))
y=[dd**3 for dd in x]
plt.scatter(x,y,s=5)
plt.title('cube numbers',fontsize=24)
plt.xlabel("value",fontsize=10)
plt.ylabel("cube",fontsize=10)
plt.tick_params(axis='both',which='major',labelsize=14)
plt.show()
15-2:彩色立方:添加颜色映射
添加绿色:
#-*-coding:GBK-*-
#-*-coding:utf-8-*-
import matplotlib.pyplot as plt
x=list(range(1,5001))
y=[dd**3 for dd in x]
plt.scatter(x,y,