我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用matplotlib.pylab.annotate()。
def plot(embeddings, labels): assert embeddings.shape[0] >= len(labels), 'More labels than embeddings' pylab.figure(figsize=(15, 15)) # in inches for i, label in enumerate(labels): x, y = embeddings[i, :] pylab.scatter(x, y) pylab.annotate(label, xy=(x, y), xytext=(5, 2), textcoords='offset points', ha='right', va='bottom') pylab.show()
def plot(embeddings, labels): assert embeddings.shape[0] >= len(labels), 'More labels than embeddings' pylab.figure(figsize=(15,15)) # in inches for i, label in enumerate(labels): x, y = embeddings[i,:] pylab.scatter(x, y) pylab.annotate(label, xy=(x, y), xytext=(5, 2), textcoords='offset points', ha='right', va='bottom') pylab.show()
def illustrate(Colors=Colors): if hasattr(Colors, 'colors'): Colors = Colors.colors from matplotlib import pylab rcParams = pylab.rcParams rcParams['pdf.fonttype'] = 42 rcParams['ps.fonttype'] = 42 rcParams['text.usetex'] = False rcParams['xtick.labelsize'] = 20 rcParams['ytick.labelsize'] = 20 rcParams['legend.fontsize'] = 25 import bnpy Data = get_data(T=1000, nDocTotal=8) for k in xrange(K): zmask = Data.TrueParams['Z'] == k pylab.plot(Data.X[zmask, 0], Data.X[zmask, 1], '.', color=Colors[k], markeredgecolor=Colors[k], alpha=0.4) sigEdges = np.flatnonzero(transPi[k] > 0.0001) for j in sigEdges: if j == k: continue dx = mus[j, 0] - mus[k, 0] dy = mus[j, 1] - mus[k, 1] pylab.arrow(mus[k, 0], mus[k, 1], 0.8 * dx, 0.8 * dy, head_width=2, head_length=4, facecolor=Colors[k], edgecolor=Colors[k]) tx = 0 - mus[k, 0] ty = 0 - mus[k, 1] xy = (mus[k, 0] - 0.2 * tx, mus[k, 1] - 0.2 * ty) ''' pylab.annotate( u'\u27F2', xy=(mus[k,0], mus[k,1]), color=Colors[k], fontsize=35, ) ''' pylab.gca().yaxis.set_ticks_position('left') pylab.gca().xaxis.set_ticks_position('bottom') pylab.axis('image') pylab.ylim([-38, 38]) pylab.xlim([-38, 38])