![]() ![]() Is_vis = annot.get_visible() #check if an annotation is visible If event.inaxes != ax: #exit if mouse is not on figure 4 Answers Sorted by: 45 If x and y are the arrays to plot, you get the coordinates of the maximum via xmax x numpy.argmax (y) ymax y.max () This can be incorporated into a function that you may simply call with your data. AnnotationBbox creates an annotation using an OffsetBox, and provides more fine-grained control than Axes.annotate. ![]() H3 = ax.scatter(x3, 圓, color=colors, s=1)Īrtists = h1 + h2 + #concatenating lists # Draw annotations if cursor in right positionĪnnot = ax.annotate("", xy=(0, 0), xytext=(-20, 20), textcoords="offset points",įig.canvas.mpl_connect("motion_notify_event",īased off Markus Dutschke" and "ImportanceOfBeingErnest", I (imo) simplified the code and made it more modular.Īlso this doesn't require additional packages to be installed. Names = np.array(list("ABCDEFGHIJKLMNO")) Plot marker and text in axis coords s.annotatemarker((0.1, 0.2). (text, xy, xytextNone, xycoordsdata, textcoordsNone, arrowpropsNone, annotationclipNone, kwargs) source. Here is a code that uses a scatter and shows an annotation upon hovering over the scatter points. These callbacks can modify the plots by adding lines, text, markers, streamlines. 4 Answers Sorted by: 58 Heres a (very) slightly slicker version of Dan Allans answer: import matplotlib.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |