# Implementation of matplotlib function
from matplotlib.axis import Tick
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
circle = plt.Circle((0, 0), 5, fc ='lightgreen')
rect = plt.Rectangle((-5, 10), 10, 5, fc ='red')
ax.add_patch(circle)
ax.add_patch(rect)
circle_tip = ax.annotate('This is a green circle.',
xy =(0, 0),xytext =(30, -30), ha ='left',
textcoords ='offset points',color ='w',
bbox = dict(boxstyle ='round, pad =.5',
fc =(.1, .1, .1, .92), ec =(1., 1., 1.),
lw = 1, zorder = 1))
rect_tip = ax.annotate('This is a red rectangle.',
xy =(-5, 10), xytext =(30, 40),color ='w',
textcoords ='offset points', ha ='left',
bbox = dict(boxstyle ='round, pad =.5',
fc =(.1, .1, .1, .92), ec =(1., 1., 1.),
lw = 1, zorder = 1))
for i, t in enumerate(ax.patches):
Tick.set_gid(t, 'patch_% d'% i)
for i, t in enumerate(ax.texts):
Tick.set_gid(t, 'tooltip_% d'% i)
ax.set_xlim(-30, 30)
ax.set_ylim(-30, 30)
ax.set_aspect('equal')
fig.suptitle('matplotlib.axis.Tick.set_gid() \
function Example', fontweight ="bold")
plt.show()