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

Sensitive data? Upgrade to a paid plan

Show Sidebar Hide Sidebar

Histograms in Julia

How to make a histogram in julia. Seven examples of colored, horizontal, and normal histogram bar charts.

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

using Plotly

x = randn(500)


data = [
  [
    "x" => x,
    "type" => "histogram"
  ]
]
response = Plotly.plot(data, ["filename" => "basic-histogram", "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

y = randn(500)


data = [
  [
    "y" => y,
    "type" => "histogram"
  ]
]
response = Plotly.plot(data, ["filename" => "horizontal-histogram", "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

x0 = randn(500)
x1 = randn(500)+1


trace1 = [
  "x" => x0,
  "opacity" => 0.75,
  "type" => "histogram"
]
trace2 = [
  "x" => x1,
  "opacity" => 0.75,
  "type" => "histogram"
]
data = [trace1, trace2]
layout = ["barmode" => "overlay"]
response = Plotly.plot(data, ["layout" => layout, "filename" => "overlaid-histogram", "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

x0 = randn(500)
x1 = randn(500)+1


trace1 = [
  "x" => x0,
  "type" => "histogram"
]
trace2 = [
  "x" => x1,
  "type" => "histogram"
]
data = [trace1, trace2]
layout = ["barmode" => "stack"]
response = Plotly.plot(data, ["layout" => layout, "filename" => "stacked-histogram", "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

x0 = randn(500)
x1 = randn(500)+1


trace1 = [
  "x" => x0,
  "histnorm" => "count",
  "name" => "control",
  "autobinx" => false,
  "xbins" => [
    "start" => -3.2,
    "end" => 2.8,
    "size" => 0.2
  ],
  "marker" => [
    "color" => "fuchsia",
    "line" => [
      "color" => "grey",
      "width" => 0
    ],
    "opacity" => 0.75
  ],
  "type" => "histogram"
]
trace2 = [
  "x" => x1,
  "name" => "experimental",
  "autobinx" => false,
  "xbins" => [
    "start" => -1.8,
    "end" => 4.2,
    "size" => 0.2
  ],
  "marker" => ["color" => "rgb(255, 217, 102)"],
  "opacity" => 0.75,
  "type" => "histogram"
]
data = [trace1, trace2]
layout = [
  "title" => "Sampled Results",
  "xaxis" => ["title" => "Value"],
  "yaxis" => ["title" => "Count"],
  "barmode" => "overlay",
  "bargap" => 0.25,
  "bargroupgap" => 0.3
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "style-histogram", "fileopt" => "overwrite"])
plot_url = response["url"]
Still need help?
Contact Us

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