Timeseries Plots
Timeseries plot are based on date index

Examples

In the example below, we plot the yearly trend of a financial dataset. First, we reset the index to the Date column.
1
<!DOCTYPE html>
2
<html lang="en">
3
4
<head>
5
<meta charset="UTF-8">
6
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7
<script src="https://cdn.plot.ly/plotly-1.2.0.min.js"></script>
8
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/bundle.min.js"></script>
9
<title>Document</title>
10
</head>
11
12
<body>
13
14
<div id="plot_div"></div>
15
<script>
16
17
dfd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
18
.then(df => {
19
20
var layout = {
21
title: 'A financial charts',
22
xaxis: {
23
title: 'Date',
24
},
25
yaxis: {
26
title: 'Count',
27
}
28
}
29
30
new_df = df.set_index({ column: "Date" })
31
new_df.plot("plot_div").line({ columns: ["AAPL.Open", "AAPL.High"], layout: layout })
32
33
}).catch(err => {
34
console.log(err);
35
})
36
37
</script>
38
</body>
39
40
</html>
Copied!
To set configuration for your plots, see the Configuring your plot page
Last modified 17d ago
Copy link