Line and Scatter Plot
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
Three common trace modes for scatter-type charts:
mode: "markers"— scatter plot (points only)mode: "lines"— line chart (no markers)mode: "lines+markers"— both
alias Plotly.{Figure, Scatter}
Figure.new()
|> Figure.add_trace(
Scatter.new(
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
mode: "markers",
name: "Scatter"
)
)
|> Figure.add_trace(
Scatter.new(
x: [2, 3, 4, 5],
y: [16, 5, 11, 9],
mode: "lines",
name: "Lines"
)
)
|> Figure.add_trace(
Scatter.new(
x: [1, 2, 3, 4],
y: [12, 9, 15, 12],
mode: "lines+markers",
name: "Lines+Markers"
)
)
|> Figure.update_layout(title: "Line and Scatter Plot")
|> Plotly.show()