Plotly is free for unlimited public use. Sign up for free!

Sensitive data? Upgrade to a paid plan

Show Sidebar Hide Sidebar

Subplots in Julia

How to make subplots in julia. Seven examples of stacked, custom-sized, and gridded subplots.

# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [1, 2, 3],
  "y" => [4, 5, 6],
  "type" => "scatter"
]
trace2 = [
  "x" => [20, 30, 40],
  "y" => [50, 60, 70],
  "xaxis" => "x2",
  "yaxis" => "y2",
  "type" => "scatter"
]
data = [trace1, trace2]
layout = [
  "xaxis" => ["domain" => [0, 0.45]],
  "yaxis2" => ["anchor" => "x2"],
  "xaxis2" => ["domain" => [0.55, 1]]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "simple-subplot", "fileopt" => "overwrite"])
plot_url = response["url"]
# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [1, 2, 3],
  "y" => [4, 5, 6],
  "type" => "scatter"
]
trace2 = [
  "x" => [20, 30, 40],
  "y" => [50, 60, 70],
  "xaxis" => "x2",
  "yaxis" => "y2",
  "type" => "scatter"
]
data = [trace1, trace2]
layout = [
  "xaxis" => ["domain" => [0, 0.7]],
  "yaxis2" => ["anchor" => "x2"],
  "xaxis2" => ["domain" => [0.8, 1]]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "custom-size-subplot", "fileopt" => "overwrite"])
plot_url = response["url"]
# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [1, 2, 3],
  "y" => [4, 5, 6],
  "type" => "scatter"
]
trace2 = [
  "x" => [20, 30, 40],
  "y" => [50, 60, 70],
  "xaxis" => "x2",
  "yaxis" => "y2",
  "type" => "scatter"
]
trace3 = [
  "x" => [300, 400, 500],
  "y" => [600, 700, 800],
  "xaxis" => "x3",
  "yaxis" => "y3",
  "type" => "scatter"
]
trace4 = [
  "x" => [4000, 5000, 6000],
  "y" => [7000, 8000, 9000],
  "xaxis" => "x4",
  "yaxis" => "y4",
  "type" => "scatter"
]
data = [trace1, trace2, trace3, trace4]
layout = [
  "xaxis" => ["domain" => [0, 0.45]],
  "yaxis" => ["domain" => [0, 0.45]],
  "xaxis4" => [
    "domain" => [0.55, 1],
    "anchor" => "y4"
  ],
  "xaxis3" => [
    "domain" => [0, 0.45],
    "anchor" => "y3"
  ],
  "xaxis2" => ["domain" => [0.55, 1]],
  "yaxis2" => [
    "domain" => [0, 0.45],
    "anchor" => "x2"
  ],
  "yaxis3" => ["domain" => [0.55, 1]],
  "yaxis4" => [
    "domain" => [0.55, 1],
    "anchor" => "x4"
  ]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "multiple-subplots", "fileopt" => "overwrite"])
plot_url = response["url"]
# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [1, 2, 3],
  "y" => [2, 3, 4],
  "type" => "scatter"
]
trace2 = [
  "x" => [20, 30, 40],
  "y" => [5, 5, 5],
  "xaxis" => "x2",
  "yaxis" => "y",
  "type" => "scatter"
]
trace3 = [
  "x" => [2, 3, 4],
  "y" => [600, 700, 800],
  "xaxis" => "x",
  "yaxis" => "y3",
  "type" => "scatter"
]
trace4 = [
  "x" => [4000, 5000, 6000],
  "y" => [7000, 8000, 9000],
  "xaxis" => "x4",
  "yaxis" => "y4",
  "type" => "scatter"
]
data = [trace1, trace2, trace3, trace4]
layout = [
  "xaxis" => ["domain" => [0, 0.45]],
  "yaxis" => ["domain" => [0, 0.45]],
  "xaxis4" => [
    "domain" => [0.55, 1],
    "anchor" => "y4"
  ],
  "xaxis2" => ["domain" => [0.55, 1]],
  "yaxis3" => ["domain" => [0.55, 1]],
  "yaxis4" => [
    "domain" => [0.55, 1],
    "anchor" => "x4"
  ]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "shared-axes-subplots", "fileopt" => "overwrite"])
plot_url = response["url"]
# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [0, 1, 2],
  "y" => [10, 11, 12],
  "type" => "scatter"
]
trace2 = [
  "x" => [2, 3, 4],
  "y" => [100, 110, 120],
  "xaxis" => "x2",
  "yaxis" => "y2",
  "type" => "scatter"
]
trace3 = [
  "x" => [3, 4, 5],
  "y" => [1000, 1100, 1200],
  "xaxis" => "x3",
  "yaxis" => "y3",
  "type" => "scatter"
]
data = [trace1, trace2, trace3]
layout = [
  "yaxis" => ["domain" => [0, 0.266]],
  "legend" => ["traceorder" => "reversed"],
  "xaxis3" => ["anchor" => "y3"],
  "xaxis2" => ["anchor" => "y2"],
  "yaxis2" => ["domain" => [0.366, 0.633]],
  "yaxis3" => ["domain" => [0.733, 1]]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "stacked-subplots", "fileopt" => "overwrite"])
plot_url = response["url"]
# Learn about API authentication here: https://plot.ly/julia/getting-started
# Find your api_key here: https://plot.ly/settings/api

using Plotly


trace1 = [
  "x" => [0, 1, 2],
  "y" => [10, 11, 12],
  "type" => "scatter"
]
trace2 = [
  "x" => [2, 3, 4],
  "y" => [100, 110, 120],
  "yaxis" => "y2",
  "type" => "scatter"
]
trace3 = [
  "x" => [3, 4, 5],
  "y" => [1000, 1100, 1200],
  "yaxis" => "y3",
  "type" => "scatter"
]
data = [trace1, trace2, trace3]
layout = [
  "yaxis" => ["domain" => [0, 0.33]],
  "legend" => ["traceorder" => "reversed"],
  "yaxis2" => ["domain" => [0.33, 0.66]],
  "yaxis3" => ["domain" => [0.66, 1]]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "stacked-coupled-subplots", "fileopt" => "overwrite"])
plot_url = response["url"]
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.