Ctrl+K
Logo image Logo image
  • Plot types
  • Examples
  • Tutorials
  • Reference
  • User guide
  • Develop
  • Release notes
  • Plot types
  • Examples
  • Tutorials
  • Reference
  • User guide
  • Develop
  • Release notes

Section Navigation

  • Lines, bars and markers
  • Images, contours and fields
  • Subplots, axes and figures
  • Statistics
  • Pie and polar charts
  • Text, labels and annotations
  • pyplot
  • Color
  • Shapes and collections
  • Style sheets
  • axes_grid1
  • axisartist
  • Showcase
  • Animation
  • Event handling
  • Miscellaneous
    • Anchored Artists
    • Changing colors of lines intersecting a box
    • Manual Contour
    • Coords Report
    • Custom projection
    • Customize Rc
    • AGG filter
    • Ribbon Box
    • Adding lines to figures
    • Fill Spiral
    • Findobj Demo
    • Font indexing
    • Font properties
    • Building histograms using Rectangles and PolyCollections
    • Hyperlinks
    • Image Thumbnail
    • Plotting with keywords
    • Matplotlib logo
    • Multipage PDF
    • Multiprocess
    • Packed-bubble chart
    • Patheffect Demo
    • Print Stdout
    • Pythonic Matplotlib
    • Rasterization for vector graphics
    • Set and get properties
    • SVG Filter 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
  • Userdemo
  • Widgets

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
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 Python source code: hyperlinks_sgskip.py

Download Jupyter notebook: hyperlinks_sgskip.ipynb

Gallery generated by Sphinx-Gallery

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

Created using Sphinx 5.2.3.