Using Tickformat (Date)
Mix.install([
{:plotly_ex, "~> 0.3"},
{:kino, "~> 0.18"}
])
Section
For date axes, tickformat uses d3-time-format specifiers. Common tokens:
%d day, %B full month name, %b abbreviated month, %a abbreviated
weekday, %Y 4-digit year. Use \n for multi-line tick labels.
alias Plotly.{Figure, Scatter}
Figure.new()
|> Figure.add_trace(
Scatter.new(
x: ["2020-01-15", "2020-02-15", "2020-03-15",
"2020-04-15", "2020-05-15", "2020-06-15"],
y: [10, 14, 12, 18, 15, 20],
mode: "lines+markers"
)
)
|> Figure.update_layout(
title: "Custom Date Tick Format",
xaxis: %{tickformat: "%d %B (%a)\n%Y"}
)
|> Plotly.show()