Tickmode - Linear (Date)
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
For date axes, dtick is specified in milliseconds. 30 days =
30 * 24 * 60 * 60 * 1000 = 2_592_000_000. tick0 is the first tick as
an ISO date string.
alias Plotly.{Figure, Scatter}
Figure.new()
|> Figure.add_trace(
Scatter.new(
x: ["2020-01-01", "2020-02-01", "2020-03-01", "2020-04-01",
"2020-05-01", "2020-06-01", "2020-07-01"],
y: [1, 3, 2, 4, 3, 5, 4],
mode: "lines+markers"
)
)
|> Figure.update_layout(
title: "Linear Tickmode - Date Axis (30-day ticks)",
xaxis: %{
tickmode: "linear",
tick0: "2020-01-01",
dtick: 2_592_000_000
}
)
|> Plotly.show()