Skip to main content
Ctrl+K
You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Matplotlib 3.10.1+dfsg1 documentation - Home Matplotlib 3.10.1+dfsg1 documentation - Home
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter

Section Navigation

  • Lines, bars and markers
  • Images, contours and fields
  • Subplots, axes and figures
  • Statistics
  • Pie and polar charts
  • Text, labels and annotations
  • Color
  • Shapes and collections
  • Style sheets
  • Module - pyplot
  • Module - axes_grid1
  • Module - axisartist
  • Showcase
  • Animation
  • Event handling
  • Miscellaneous
    • Anchored Artists
    • Identify whether artists intersect
    • Manual Contour
    • Coords Report
    • Custom projection
    • Customize Rc
    • AGG filter
    • Ribbon box
    • Add lines directly to a figure
    • Fill spiral
    • Findobj Demo
    • Font indexing
    • Font properties
    • Building histograms using Rectangles and PolyCollections
    • Hyperlinks
    • Image thumbnail
    • Plotting with keywords
    • Matplotlib logo
    • Multipage PDF
    • Multiprocessing
    • Packed-bubble chart
    • Patheffect Demo
    • Print image to stdout
    • Rasterization for vector graphics
    • Set and get properties
    • Apply SVG filter to a line
    • SVG filter pie
    • Table Demo
    • TickedStroke patheffect
    • transforms.offset_copy
    • Zorder Demo
  • 3D plotting
  • Scales
  • Specialty plots
  • Spines
  • Ticks
  • Units
  • Embedding Matplotlib in graphical user interfaces
  • Widgets
  • Userdemo
  • Examples
  • Miscellaneous
  • Hyperlinks

Note

Go to the end 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 matplotlib.pyplot as plt
import numpy as np

import matplotlib.cm as cm
fig = plt.figure()
s = plt.scatter([1, 2, 3], [4, 5, 6])
s.set_urls(['https://www.bbc.com/news', 'https://www.google.com/', None])
fig.savefig('scatter.svg')
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('https://www.google.com/')
fig.savefig('image.svg')

Download Jupyter notebook: hyperlinks_sgskip.ipynb

Download Python source code: hyperlinks_sgskip.py

Download zipped: hyperlinks_sgskip.zip

Gallery generated by Sphinx-Gallery

© Copyright 2002–2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012–2025 The Matplotlib development team.

Created using Sphinx 8.1.3.

Built from 3.10.1+dfsg1.

Built with the PyData Sphinx Theme 0.16.1.