@@ -29,8 +29,6 @@ def draw_path(data, path, draw_options=None, simplify=None):
29
29
xformat = "{}" if x_is_date else ff
30
30
prev = None
31
31
for vert , code in path .iter_segments (simplify = simplify ):
32
- if x_is_date :
33
- vert = [num2date (vert [0 ]), vert [1 ]]
34
32
# nschloe, Oct 2, 2015:
35
33
# The transform call yields warnings and it is unclear why. Perhaps
36
34
# the input data is not suitable? Anyhow, this should not happen.
@@ -43,8 +41,12 @@ def draw_path(data, path, draw_options=None, simplify=None):
43
41
# if code == mpl.path.Path.STOP: pass
44
42
is_area = False
45
43
if code == mpl .path .Path .MOVETO :
44
+ if x_is_date :
45
+ vert = [num2date (vert [0 ]), vert [1 ]]
46
46
nodes .append (("(axis cs:" + xformat + "," + ff + ")" ).format (* vert ))
47
47
elif code == mpl .path .Path .LINETO :
48
+ if x_is_date :
49
+ vert = [num2date (vert [0 ]), vert [1 ]]
48
50
nodes .append (("--(axis cs:" + xformat + "," + ff + ")" ).format (* vert ))
49
51
elif code == mpl .path .Path .CURVE3 :
50
52
# Quadratic Bezier curves aren't natively supported in TikZ, but
@@ -68,41 +70,54 @@ def draw_path(data, path, draw_options=None, simplify=None):
68
70
Q1 = 1.0 / 3.0 * prev + 2.0 / 3.0 * vert [0 :2 ]
69
71
Q2 = 2.0 / 3.0 * vert [0 :2 ] + 1.0 / 3.0 * vert [2 :4 ]
70
72
Q3 = vert [2 :4 ]
73
+ if x_is_date :
74
+ Q1 = [num2date (Q1 [0 ]), Q1 [1 ]]
75
+ Q2 = [num2date (Q2 [0 ]), Q2 [1 ]]
76
+ Q3 = [num2date (Q3 [0 ]), Q3 [1 ]]
71
77
nodes .append (
72
78
(
73
79
".. controls (axis cs:"
74
- + ff
80
+ + xformat
75
81
+ ","
76
82
+ ff
77
83
+ ") "
78
84
+ "and (axis cs:"
79
- + ff
85
+ + xformat
80
86
+ ","
81
87
+ ff
82
88
+ ") "
83
89
+ ".. (axis cs:"
84
- + ff
90
+ + xformat
85
91
+ ","
86
92
+ ff
87
93
+ ")"
88
94
).format (Q1 [0 ], Q1 [1 ], Q2 [0 ], Q2 [1 ], Q3 [0 ], Q3 [1 ])
89
95
)
90
96
elif code == mpl .path .Path .CURVE4 :
91
97
# Cubic Bezier curves.
98
+ if x_is_date :
99
+ vert = [
100
+ num2date (vert [0 ]),
101
+ vert [1 ],
102
+ num2date (vert [2 ]),
103
+ vert [3 ],
104
+ num2date (vert [4 ]),
105
+ vert [5 ],
106
+ ]
92
107
nodes .append (
93
108
(
94
109
".. controls (axis cs:"
95
- + ff
110
+ + xformat
96
111
+ ","
97
112
+ ff
98
113
+ ") "
99
114
+ "and (axis cs:"
100
- + ff
115
+ + xformat
101
116
+ ","
102
117
+ ff
103
118
+ ") "
104
119
+ ".. (axis cs:"
105
- + ff
120
+ + xformat
106
121
+ ","
107
122
+ ff
108
123
+ ")"
0 commit comments