I wanted to do what the article title says. Make a note of how you do it, as you may use it again.
--Create linked graphs with matplotlib
--Save in svg
format
--Open the file in a browser such as Chrome
I was working on jupyter-lab. The version looks like this (from the result of pip freeze)
jupyterlab-server==1.0.7
matplotlib==3.2.1
#various settings
import matplotlib.pyplot as plt
from IPython.display import set_matplotlib_formats
set_matplotlib_formats("svg")
#Test data preparation
data_list = [[0, 1], [1,0], [1,1]]
label_list = ['google', 'yahoo', 'lightcafe']
url_list = ['https://www.google.com/', 'https://www.yahoo.co.jp/', 'https://www.lightcafe.co.jp/']
#Graph creation
fig, ax = plt.subplots(1, 1, tight_layout=True)
for d, l, u in zip(data_list, label_list, url_list):
x, y = d
ax.scatter(x, y) #Point plot
ax.annotate(l, xy=(x, y), size=10, #Character plot
url=u,
bbox=dict(color='w', alpha=1e-6, url=u),
)
#Save
fig.savefig('test.svg')
Open test.svg
in your browser and click on the data points or labels in the graph
Jump to the set link.
By the way, if you run the same thing in Google Colaboratory, you don't have to save svg I was able to fly from the output of the cell.
that's all
Recommended Posts