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

Sensitive data? Upgrade to a paid plan

Show Sidebar Hide Sidebar

Error Bars in Julia

How to add error bars to a line, scatter, or bar chart. Seven examples of symmetric, asymmetric, horizontal, and colored error bars.

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

using Plotly


data = [
  [
    "x" => [0, 1, 2],
    "y" => [6, 10, 2],
    "error_y" => [
      "type" => "data",
      "array" => [1, 2, 3],
      "visible" => true
    ],
    "type" => "scatter"
  ]
]
response = Plotly.plot(data, ["filename" => "basic-error-bar", "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" => ["Trial 1", "Trial 2", "Trial 3"],
  "y" => [3, 6, 4],
  "name" => "Control",
  "error_y" => [
    "type" => "data",
    "array" => [1, 0.5, 1.5],
    "visible" => true
  ],
  "type" => "bar"
]
trace2 = [
  "x" => ["Trial 1", "Trial 2", "Trial 3"],
  "y" => [4, 7, 3],
  "name" => "Experimental",
  "error_y" => [
    "type" => "data",
    "array" => [0.5, 1, 2],
    "visible" => true
  ],
  "type" => "bar"
]
data = [trace1, trace2]
layout = ["barmode" => "group"]
response = Plotly.plot(data, ["layout" => layout, "filename" => "error-bar-bar", "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


data = [
  [
    "x" => [1, 2, 3, 4],
    "y" => [2, 1, 3, 4],
    "error_x" => [
      "type" => "percent",
      "value" => 10
    ],
    "type" => "scatter"
  ]
]
response = Plotly.plot(data, ["filename" => "error-bar-horizontal", "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


data = [
  [
    "x" => [1, 2, 3, 4],
    "y" => [2, 1, 3, 4],
    "error_y" => [
      "type" => "data",
      "symmetric" => false,
      "array" => [0.1, 0.2, 0.1, 0.1],
      "arrayminus" => [0.2, 0.4, 1, 0.2]
    ],
    "type" => "scatter"
  ]
]
response = Plotly.plot(data, ["filename" => "error-bar-asymmetric-array", "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

x_theo = linspace(-4, 4, 100)
sincx = sinc(x_theo)
x = [-3.8, -3.03, -1.91, -1.46, -0.89, -0.24, -0.0, 0.41, 0.89, 1.01, 1.91, 2.28, 2.79, 3.56]
y = [-0.02, 0.04, -0.01, -0.27, 0.36, 0.75, 1.03, 0.65, 0.28, 0.02, -0.11, 0.16, 0.04, -0.15]


trace1 = [
  "x" => x_theo,
  "y" => sincx,
  "name" => "sinc(x)",
  "type" => "scatter"
]
trace2 = [
  "x" => x,
  "y" => y,
  "mode" => "markers",
  "name" => "measured",
  "error_y" => [
    "type" => "constant",
    "value" => 0.1,
    "color" => "#85144B",
    "thickness" => 1.5,
    "width" => 3,
    "opacity" => 1
  ],
  "error_x" => [
    "type" => "constant",
    "value" => 0.2,
    "color" => "#85144B",
    "thickness" => 1.5,
    "width" => 3,
    "opacity" => 1
  ],
  "marker" => [
    "color" => "#85144B",
    "size" => 8
  ],
  "type" => "scatter"
]
data = [trace1, trace2]
response = Plotly.plot(data, ["filename" => "error-bar-style", "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


data = [
  [
    "x" => [0, 1, 2],
    "y" => [6, 10, 2],
    "error_y" => [
      "type" => "percent",
      "value" => 50,
      "visible" => true
    ],
    "type" => "scatter"
  ]
]
response = Plotly.plot(data, ["filename" => "percent-error-bar", "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


data = [
  [
    "x" => [1, 2, 3, 4],
    "y" => [2, 1, 3, 4],
    "error_y" => [
      "type" => "percent",
      "symmetric" => false,
      "value" => 15,
      "valueminus" => 25
    ],
    "type" => "scatter"
  ]
]
response = Plotly.plot(data, ["filename" => "error-bar-asymmetric-constant", "fileopt" => "overwrite"])
plot_url = response["url"]
Still need help?
Contact Us

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