API for coders REST API
Julia
How to use PlotAPI with Julia.
In this demonstration, we'll use some sample data to create an interactive PlotAPI Chord diagram with Julia.
using HTTP
using JSON
using Base64
matrix = [
[0, 5, 6, 4, 7, 4],
[5, 0, 5, 4, 6, 5],
[6, 5, 0, 4, 5, 5],
[4, 4, 4, 0, 5, 5],
[7, 6, 5, 5, 0, 4],
[4, 5, 5, 5, 4, 0],
]
names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
params = Dict("matrix" => matrix, "names" => names)
auth = "Basic " * Base64.base64encode("api_key" * ":" * your_api_key)
r = HTTP.request("POST", "https://plotapi.com/chord",
["Content-Type" => "application/json", "Authorization" => auth],
JSON.json(params))
html_content = String(r.body)
Saving locally
We can save the to a HTML file.
open("plot.html", "w") do io
write(io, html_content)
end;
Displaying in notebook
When working from a Jupyter Notebook, you can also make use of display()
and HTML()
to display the visualization inline.
display(HTML(html_content))