1
1
import matplotlib as mpl
2
2
import numpy
3
3
from matplotlib .markers import MarkerStyle
4
+ from matplotlib .dates import num2date , DateConverter
4
5
5
6
from . import _color
6
7
from ._axes import _mpl_cmap2pgf_cmap
@@ -22,10 +23,14 @@ def draw_path(data, path, draw_options=None, simplify=None):
22
23
):
23
24
return data , "" , None , False
24
25
26
+ x_is_date = isinstance (data ["current mpl axes obj" ].xaxis .converter , DateConverter )
25
27
nodes = []
26
28
ff = data ["float format" ]
29
+ xformat = "{}" if x_is_date else ff
27
30
prev = None
28
31
for vert , code in path .iter_segments (simplify = simplify ):
32
+ if x_is_date :
33
+ vert = [num2date (vert [0 ]), vert [1 ]]
29
34
# nschloe, Oct 2, 2015:
30
35
# The transform call yields warnings and it is unclear why. Perhaps
31
36
# the input data is not suitable? Anyhow, this should not happen.
@@ -38,9 +43,9 @@ def draw_path(data, path, draw_options=None, simplify=None):
38
43
# if code == mpl.path.Path.STOP: pass
39
44
is_area = False
40
45
if code == mpl .path .Path .MOVETO :
41
- nodes .append (("(axis cs:" + ff + "," + ff + ")" ).format (* vert ))
46
+ nodes .append (("(axis cs:" + xformat + "," + ff + ")" ).format (* vert ))
42
47
elif code == mpl .path .Path .LINETO :
43
- nodes .append (("--(axis cs:" + ff + "," + ff + ")" ).format (* vert ))
48
+ nodes .append (("--(axis cs:" + xformat + "," + ff + ")" ).format (* vert ))
44
49
elif code == mpl .path .Path .CURVE3 :
45
50
# Quadratic Bezier curves aren't natively supported in TikZ, but
46
51
# can be emulated as cubic Beziers.
0 commit comments