颜色映射(colomap)是一系列颜色,他们从颜色渐变到结束颜色。
输出结果:
?
3、随机漫步:每次决策都是随机决定的。...1:向右 -1: 向左'
x_distance = choice([0,1,2,3,4,5])
'随机漫步的距离'
x_step...y_distance = choice([0,1,2,3,4,5])
y_step = y_direction * y_distance
if x_step...-1] + x_step
'确定 点的 新位置'
next_y =self.y_value[-1] + y_step
self.x_value.append...补充:
如果想使得输出的图像大小适合屏幕大小,可以使用:plt.figure(dpi=128,figsize=(20,10)) 其中向dpi传递是分辨率,向figsize传递以元组,指定绘图窗口的尺寸。