Reputation: 2202
I am creating a visualization of Twitter user locations as tweets come in, and so within my matplotlib code I have these three lines to create an interactive plot so the location markers can be plotted in realtime:
import matplotlib.pyplot as plt
plt.ion()
plt.show()
What I'd like to do is add links to the original Tweet page within each marker. So if you hover over a newly-added marker, you can click it and it opens up a browser and shows you the tweet.
I'm hoping there's a way to add hyperlinks that are clickable in real-time, but I'm okay with saving the visualization to an .svg and then seeing the links appear in a static file within my browser. I see this example page on how to do it, but it includes a plt.figure() statement which I don't have in my code. How can I still produce the .svg with hyperlinks while running in interactive mode?
Upvotes: 1
Views: 511
Reputation: 44
A possible solution you could try is by using the matplotlib.use('SVG') before you use savefig.
Straight from the FAQ (http://matplotlib.org/faq/howto_faq.html) You have:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.savefig('myfig')
Replace Agg with SVG and hopefully that will work for you.
Upvotes: 1