I want to do a pie chart in matplotlib.
This pie chart will be a representation of two variables: male and female.
That’s easy to do 🙂
What I would like to do next, I’m not even sure if it’s possible to do with matplotlib, I would like to make these two variables clickable so if I click on male, I would see another page with information about this, same thing with female.
Image map isn’t a solution since this variables may change in the future.
Anyone has any idea how to do this? If it’s possible with matplotlib or what program would you recommend.
Thank you!
While it’s not really in a workably stable state yet, have a look at the html5 canvas backend for matplotlib. It looks interesting, anyway, and will probably be the best way to do this sort of thing (interactive webpage with a matplotlib plot) in the future.
In the meantime, as @Mark suggested, it’s not too hard to dynamically generate an imagemap for the wedges of a pie plot.
Here’s a rough example, that I’m sure you could adapt to whatever web framework you’re using.
Edit: I just realized that you might not be referring to embedding the plot into a web page… (I assumed that you were from the “display another page” bit in your question.) If you want more of a desktop app, without having to mess with a “full” gui toolkit, you can do something like this:
Which opens a browser window for a google image search of whatever the wedge is labeled as…