Skip to content

Commit 4d7bd27

Browse files
authored
Merge pull request #287 from nschloe/date-lim
Limits on date axes
2 parents 3655e28 + 3b551ca commit 4d7bd27

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

matplotlib2tikz/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
__email__ = "[email protected]"
55
__copyright__ = u"Copyright (c) 2010-2019, {} <{}>".format(__author__, __email__)
66
__license__ = "License :: OSI Approved :: MIT License"
7-
__version__ = "0.7.1"
7+
__version__ = "0.7.2"
88
__status__ = "Development Status :: 5 - Production/Stable"

matplotlib2tikz/line2d.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
from __future__ import print_function
44

5+
from matplotlib.dates import num2date
56
import datetime
67
import six
78

@@ -302,15 +303,22 @@ def _table(obj, data):
302303
xdata = [date.strftime("%Y-%m-%d %H:%M") for date in xdata]
303304
xformat = "{}"
304305
col_sep = ","
305-
content.append("table [col sep=comma] {%\n")
306+
content.append("table [header=false,col sep=comma] {%\n")
306307
data["current axes"].axis_options.append("date coordinates in=x")
307-
# Remove xmin/xmax until <https://github.com/matplotlib/matplotlib/issues/13727>
308-
# is resolved.
308+
# Replace float xmin/xmax by datetime
309+
# <https://github.com/matplotlib/matplotlib/issues/13727>.
309310
data["current axes"].axis_options = [
310311
option
311312
for option in data["current axes"].axis_options
312313
if not option.startswith("xmin")
313314
]
315+
xmin, xmax = data["current mpl axes obj"].get_xlim()
316+
data["current axes"].axis_options.append(
317+
"xmin={}, xmax={}".format(
318+
num2date(xmin).strftime("%Y-%m-%d %H:%M"),
319+
num2date(xmax).strftime("%Y-%m-%d %H:%M"),
320+
)
321+
)
314322
else:
315323
xformat = ff
316324
col_sep = " "

matplotlib2tikz/save.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def _recurse(data, obj):
337337
if data["extra axis options [base]"]:
338338
ax.axis_options.extend(data["extra axis options [base]"])
339339

340+
data["current mpl axes obj"] = child
340341
data["current axes"] = ax
341342

342343
# Run through the child objects, gather the content.

test/test_datetime_reference.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
tick align=outside,
88
tick pos=left,
99
x grid style={white!69.01960784313725!black},
10+
xmin=2016-10-10 17:59, xmax=2016-10-10 18:15,
1011
y grid style={white!69.01960784313725!black},
1112
ymin=49.999, ymax=50.021
1213
]
1314
\addplot [semithick, color0]
14-
table [col sep=comma] {%
15+
table [header=false,col sep=comma] {%
1516
2016-10-10 18:00,50
1617
2016-10-10 18:15,50.02
1718
};

0 commit comments

Comments
 (0)