From 8cf612dbe8a9f63901e07d0d95f9766300ace71e Mon Sep 17 00:00:00 2001 From: Tariq Bakhtali <tariquake@hotmail.com> Date: Mon, 21 Nov 2022 00:57:21 +0100 Subject: [PATCH] Delete test.py --- python/test.py | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 python/test.py diff --git a/python/test.py b/python/test.py deleted file mode 100644 index 4fe3085e..00000000 --- a/python/test.py +++ /dev/null @@ -1,46 +0,0 @@ -import matplotlib.pyplot as plt -import numpy as np; np.random.seed(1) - -x = np.random.rand(15) -y = np.random.rand(15) -names = np.array(list("ABCDEFGHIJKLMNO")) -c = np.random.randint(1,5,size=15) - -norm = plt.Normalize(1,4) -cmap = plt.cm.RdYlGn - -fig,ax = plt.subplots() -sc = plt.scatter(x,y,c=c, s=100, cmap=cmap, norm=norm) - -annot = ax.annotate("", xy=(0,0), xytext=(20,20),textcoords="offset points", - bbox=dict(boxstyle="round", fc="w"), - arrowprops=dict(arrowstyle="->")) -annot.set_visible(False) - -def update_annot(ind): - - pos = sc.get_offsets()[ind["ind"][0]] - annot.xy = pos - text = "{}, {}".format(" ".join(list(map(str,ind["ind"]))), - " ".join(names[ind["ind"]])) - annot.set_text(text) - annot.get_bbox_patch().set_facecolor(cmap(norm(c[ind["ind"][0]]))) - annot.get_bbox_patch().set_alpha(0.4) - - -def hover(event): - vis = annot.get_visible() - if event.inaxes == ax: - cont, ind = sc.contains(event) - if cont: - update_annot(ind) - annot.set_visible(True) - fig.canvas.draw_idle() - else: - if vis: - annot.set_visible(False) - fig.canvas.draw_idle() - -fig.canvas.mpl_connect("motion_notify_event", hover) - -plt.show() \ No newline at end of file -- GitLab