当前位置 : 主页 > 编程语言 > python >

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

来源:互联网 收集:自由互联 发布时间:2021-04-09
Matplotlib编程实现 import matplotlib.pyplot as pltimport numpy as npfrom matplotlib.widgets import Cursorlineprops = dict(color="red", lw=2)fig, ax = plt.subplots(1, 1, subplot_kw=dict(facecolor="lemonchiffon"))x = np.random.random(100)

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()

成品截图

说明

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

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

到此这篇关于Matplotlib使用Cursor实现UI定位的示例代码的文章就介绍到这了,更多相关Matplotlib UI定位内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

网友评论