Ai
1 Star 0 Fork 0

leetone/my_python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rw_visual.py 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
leetone 提交于 2018-08-15 13:10 +08:00 . 随机步数的散点图
import matplotlib.pyplot as plt
from random_walk import RandomWalk
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
#只要程序处于活动状态,就可以不断的模拟漫步
while True:
#创建实例
rw = RandomWalk()
rw.fill_walk()
#plt.scatter(rw.x_values,rw.y_values,s=15)
#设置绘图窗口的尺寸
plt.figure(dpi=130, figsize = (11,5))
#随颜色渐变,cmap
point_numbers = list(range(rw.num_points))
plt.scatter(rw.x_values,rw.y_values,c=point_numbers,cmap=plt.cm.Reds,edgecolor='none',s=15)
#设置图表标题,并给坐标轴加上标签
plt.title("5000个随机点图标",fontsize=24,fontproperties=font_set)
plt.xlabel("向左1步",fontsize=14,fontproperties=font_set)
plt.ylabel("向右1步",fontsize=14,fontproperties=font_set)
#突出起点和终点
plt.scatter(0,0,c='green',edgecolors='none',s=100)
plt.scatter(rw.x_values[-1],rw.y_values[-1],c='blue',edgecolors='none',s=100)
#隐藏坐标轴(后台会报错,提示不建议使用)
# plt.axes().get_xaxis().set_visible(False)
# plt.axes().get_yaxis().set_visible(False)
plt.show()
#输入no就终止
keep_running = input("Make another walk? (y/n): ")
if keep_running == 'n':
break
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/leetone123/my_python.git
git@gitee.com:leetone123/my_python.git
leetone123
my_python
my_python
master

搜索帮助