You are reading an old version of the documentation (v3.2.1). For the latest version see https://matplotlib.org/stable/gallery/misc/hyperlinks_sgskip.html

John Hunter Excellence in Plotting Contest 2020 submissions are open! Entries are due June 1, 2020.

Version 3.2.1
matplotlib
Fork me on GitHub
  • Installation
  • Documentation
  • Examples
  • Tutorials
  • Contributing

Navigation

  • index
  • modules |
  • home| 
  • contents »

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
f = 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])
f.savefig('scatter.svg')
f = 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')
f.savefig('image.svg')
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 - 2018 The Matplotlib development team.
Last updated on Apr 08, 2020. Created using Sphinx 3.0.0. Doc version v3.2.1-13-g7a9bc5ebb-dirty.