超链接

此示例演示如何在各种元素上设置超链接。

这目前只适用于SVG后端。

  1. import numpy as np
  2. import matplotlib.cm as cm
  3. import matplotlib.pyplot as plt
  1. f = plt.figure()
  2. s = plt.scatter([1, 2, 3], [4, 5, 6])
  3. s.set_urls(['http://www.bbc.co.uk/news', 'http://www.google.com', None])
  4. f.savefig('scatter.svg')
  1. f = plt.figure()
  2. delta = 0.025
  3. x = y = np.arange(-3.0, 3.0, delta)
  4. X, Y = np.meshgrid(x, y)
  5. Z1 = np.exp(-X**2 - Y**2)
  6. Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
  7. Z = (Z1 - Z2) * 2
  8. im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
  9. origin='lower', extent=[-3, 3, -3, 3])
  10. im.set_url('http://www.google.com')
  11. f.savefig('image.svg')

下载这个示例