Skip to content

Commit 8322565

Browse files
committed
Add test for datetime paths
1 parent 6f5375c commit 8322565

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

test/test_datetime_paths.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import datetime as date
2+
3+
import matplotlib.pyplot as plt
4+
from matplotlib import dates
5+
6+
from helpers import assert_equality
7+
8+
9+
def plot():
10+
fig = plt.figure()
11+
12+
times = [date.datetime(2020, 1, 1, 12, 00), date.datetime(2020, 1, 2, 12, 00)]
13+
line = [2, 2]
14+
upper = [3, 4]
15+
lower = [1, 0]
16+
17+
plt.plot(times, line)
18+
plt.fill_between(times, lower, upper)
19+
ax = plt.gca()
20+
ax.fmt_xdata = dates.DateFormatter("%d %b %Y %H:%M:%S")
21+
22+
return fig
23+
24+
25+
def test():
26+
assert_equality(plot, __file__[:-3] + "_reference.tex")
27+
return
28+
29+
30+
if __name__ == "__main__":
31+
import helpers
32+
33+
helpers.compare_mpl_latex(plot)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
\begin{tikzpicture}
2+
3+
\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}
4+
5+
\begin{axis}[
6+
date coordinates in=x,
7+
tick align=outside,
8+
tick pos=left,
9+
x grid style={white!69.01960784313725!black},
10+
xmin=2020-01-01 10:48, xmax=2020-01-02 13:12,
11+
xtick style={color=black},
12+
y grid style={white!69.01960784313725!black},
13+
ymin=-0.2, ymax=4.2,
14+
ytick style={color=black}
15+
]
16+
\path [fill=color0]
17+
(axis cs:2020-01-01 12:00:00+00:00,3)
18+
--(axis cs:2020-01-01 12:00:00+00:00,1)
19+
--(axis cs:2020-01-02 12:00:00+00:00,0)
20+
--(axis cs:2020-01-02 12:00:00+00:00,4)
21+
--(axis cs:2020-01-02 12:00:00+00:00,4)
22+
--(axis cs:2020-01-01 12:00:00+00:00,3)
23+
--cycle;
24+
25+
\addplot [semithick, color0]
26+
table [header=false,col sep=comma] {%
27+
2020-01-01 12:00,2
28+
2020-01-02 12:00,2
29+
};
30+
\end{axis}
31+
32+
\end{tikzpicture}

0 commit comments

Comments
 (0)