Show Sidebar Hide Sidebar

Getting Started Plotly for Julia

Plotly's Julia graphing library makes interactive, publication-quality graphs online. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts and bubble charts.

Getting started: Plotly for Julia

Installation

Install using Julia's Pkg module. From the Julia REPL:

Pkg.clone("https://github.com/plotly/Plotly.jl")

Initialization

In the Julia console, begin by importing the Plotly Julia library.

using Plotly

Authentication

Next, set your Plotly user credentials.

It is also possible to save your user credentials for future Julia sessions. In your Julia terminal, enter:

Plotly.set_credentials_file({"username"=>"DemoAccount","api_key"=>"lr1c37zw81"})

You'll need to replace "DemoAccount" and "lr1c37zw81" with your Plotly username and API key.

Find my API key.

You only have to set this up if it's your first time using a Plotly API.

Special Instructions for Chart Studio Enterprise users

If your company has a Chart Studio Enterprise server, change the API endpoint so that it points to your company's Plotly server instead of Plotly's cloud.

In your Julia console, enter:


Plotly.set_config_file({"plotly_domain"=>"https://plotly.your-company.com", "plotly_api_domain"=>"https://api-plotly.your-company.com"})

Make sure to replace "your-company.com" with the URL of your Chart Studio Enterprise server.Questions? support@plot.ly

Start plotting!

Now you can make a simple API call using Plotly.plot(), and create your first graph!

trace1 = [
  "x" => [1, 2, 3, 4],
  "y" => [10, 15, 13, 17],
  "type" => "scatter"
]
trace2 = [
  "x" => [1, 2, 3, 4],
  "y" => [16, 5, 11, 9],
  "type" => "scatter"
]

response = Plotly.plot([trace1, trace2], ["filename" => "basic-line", "fileopt" => "overwrite"])
plot_url = response["url"]

Response

Here is the response you'll receive (copy and paste the URL into your browser to see your graph!)

["url"=>"http://plot.ly/~username/888",
"filename"=>"filename",
"error"=>"",
"message"=>"",
"warning"=>""]

Credentials

The initialization step places a special .plotly/.credentials file in your home directory. Your ~/.plotly/.credentials file should look something like this:


{
    "username": "DemoAccount",
    "stream_ids": ["ylosqsyet5", "h2ct8btk1s", "oxz4fm883b"],
    "api_key": "lr1c37zw81"
}
            

You can change the contents of this file manually or as described in the Initialization section.