You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Version 3.3.0rc1+229.g97785f2e6
matplotlib
Fork me on GitHub
  • Installation
  • Documentation
  • Examples
  • Tutorials
  • Contributing

Navigation

  • index
  • modules |
  • home| 
  • contents »
  • Hyperlinks

Related Topics

  • Documentation overview
Show Page Source

Note

Click here to download the full example code

Hyperlinks¶

This example demonstrates how to set a hyperlinks on various kinds of elements.

This currently only works with the SVG backend.

import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
Copy to clipboard
fig = plt.figure()
s = plt.scatter([1, 2, 3], [4, 5, 6])
s.set_urls(['http://www.bbc.co.uk/news', 'http://www.google.com', None])
fig.savefig('scatter.svg')
Copy to clipboard
fig = plt.figure()
delta = 0.025
x = y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-X**2 - Y**2)
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
Z = (Z1 - Z2) * 2

im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
                origin='lower', extent=[-3, 3, -3, 3])

im.set_url('http://www.google.com')
fig.savefig('image.svg')
Copy to clipboard
Download Python source code: hyperlinks_sgskip.py
Download Jupyter notebook: hyperlinks_sgskip.ipynb

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2020 The Matplotlib development team.
Last updated on Jul 12, 2020. Created using Sphinx 3.1.2. Doc version v3.3.0rc1-229-g97785f2e6.