From f709374c436d62ffb9a86d6061afd64d47235bae Mon Sep 17 00:00:00 2001 From: CapooL <2053217188@qq.com> Date: Mon, 24 Apr 2023 21:22:46 +0800 Subject: [PATCH] Update drawTest.py --- .idea/.gitignore | 3 +++ .idea/camera_ranging-positioning.iml | 8 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ drawTest.py | 23 +++++++++++++++---- 7 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/camera_ranging-positioning.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/camera_ranging-positioning.iml b/.idea/camera_ranging-positioning.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/camera_ranging-positioning.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b3f98fe --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e11cb69 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/drawTest.py b/drawTest.py index 763f119..5b2770b 100644 --- a/drawTest.py +++ b/drawTest.py @@ -14,9 +14,12 @@ def init(): ln.set_data(x_data, y_data) return ln - +# 设置画布 fig, ax = plt.subplots() + +# 列表存储x,y数据 x_data, y_data = [], [] +# 画图 ln, = ax.plot([], [], 'b-') # 图像格式为蓝色实线 @@ -34,11 +37,23 @@ def update(frame, camera): # 纵坐标操作同上 if camera >= y_max: ax.set_ylim(y_min, 2 * y_max) + # 更新绘图对象的数据 ln.set_data(x_data, y_data) return ln -# 利用functools.partial传入多个参数 +# 利用functools.partial传入位置参数和关键字 # 此处camera的传值没写,根据需要传入,作为纵坐标 -ani = animation.FuncAnimation(fig, functools.partial(update, camera= ), frames=1000, init_func=init, interval=100) -plt.show() \ No newline at end of file +ani = animation.FuncAnimation(fig, functools.partial(update, camera=), frames=1000, init_func=init, interval=100) +# 展示图像 +plt.show() + +# FuncAnimation参数说明 +""" + fig: 画布参数 + func: 在本函数中即第二个参数,在每帧中调用的函数(本程序为update),第一个位置参数必须为frame,要传入多个位置参数使用partial方法 + frames: 动画长度,一次循环包含的帧数,在函数运行时,其值会传递给函数update(frame)的形参"frame" + init_func: 自定义开始帧,初始化函数,即设计的init函数 + interval: 图像更新频率,以ms为单位 + +""" \ No newline at end of file