网络编程
位置:首页>> 网络编程>> Python编程>> Matplotlib使用Cursor实现UI定位的示例代码

Matplotlib使用Cursor实现UI定位的示例代码

作者:进阶的JFarmer  发布时间:2022-04-18 15:27:13 

标签:Matplotlib,Cursor,UI定位

Matplotlib编程实现


import matplotlib.pyplot as plt
import numpy as np
from matplotlib.widgets import Cursor

lineprops = dict(color="red", lw=2)

fig, ax = plt.subplots(1, 1, subplot_kw=dict(facecolor="lemonchiffon"))

x = np.random.random(100)
y = np.random.random(100)
ax.scatter(x, y, marker="o", color="red")
ax.set_xlim(-0.02, 1.02)
ax.set_ylim(-0.02, 1.02)

cursor = Cursor(ax, useblit=True, **lineprops)

plt.show()

成品截图

Matplotlib使用Cursor实现UI定位的示例代码

说明

这是一个动态的UI效果图,所以自己体验体验就知道了,挺好玩儿的。

如果使用PyCharm生成了静态的图,而不是动态的,请看这篇博文 → Here

来源:https://blog.csdn.net/weixin_43896318/article/details/104332585

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com