Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:50:13+00:00 2026-06-13T12:50:13+00:00

In matplotlib , it is possible to create SVG figures with hyperlinks . For

  • 0

In matplotlib, it is possible to create SVG figures with hyperlinks.

For example, I can use the scatter method to draw markers so that each individual marker is a hyperlink.

However, some of my markers have text labels that I have created with the text method. Can I somehow turn the text labels into hyperlinks as well?


So far I have been able to achieve the following. First, create a text label with a bounding box so that the bbox dictionary has a url parameter:

ax.text(x, y, label, bbox=dict(boxstyle=..., url=url))

Then patch matplotlib/backends/backend_svg.py (version 1.1.1) slightly, replacing

self.writer.end('</a>')

with

self.writer.end('a')

Now it almost works. I can click on the area that surrounds the text, but not the text itself (put otherwise, if I have black text on white background, I can click anywhere in the white parts, but not in the black parts).


What is the easiest way to turn the entire text label into a hyperlink (both the text and its bounding box)?

Ideally, I would prefer a solution that does not require that I patch the matplotlib library.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:50:14+00:00Added an answer on June 13, 2026 at 12:50 pm

    The following solution seems to work fine.

    • Set the gid attribute of the text element to a unique string:

      ax.text(x, y, label, gid='foo')
      
    • Create the SVG file as usual; there are no hyperlinks yet.

    • Use, e.g., lxml to parse the SVG file. Find the unique <g> element with the attribute id="foo". Modify the XML tree: replace <g>...</g> with <a ...><g>...</g></a>. Save the result.

    The same approach seems to work in general; many elements accept a gid parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a scatter plot using matplotlib. If I want to use
I'm currently using Matplotlib to create a histogram: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as
I am trying to create an animation in matplotlib that updates three artists, including
HI, is it possible that I created a image from matplotlib and I save
Is it possible to increase the antialiasing in matplotlib? I can still see some
I want to use a python module on my django website (matplotlib) that isn't
I'd like to create ellipses in matplotlib with a fill color that has an
Possible Duplicate: Is there a way of drawing a caption box in matplotlib Is
I am new to Matplotlib and Python. I mostly use Matlab. Currently, I am
I am using Python matplotlib. i want to superimpose scatter plots. I know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.