'int' object has no attribute 'strftime'
SvenA098072 opened this issue · comments
Hi,
I have an issue with datetime axis:
Packages
matplotlib 3.3.4
tikzplotlib 0.9.12
Example
import matplotlib.pyplot as plt
import matplotlib.dates as md
import numpy as np
import tikzplotlib
plt.style.use("seaborn-whitegrid")
xfmt = md.DateFormatter('%H:%M')
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
t = mega_cdf.index.tolist() # datetime index
s = cdf["mean_delta"]/cdf["mean_delta"].max()
s = np.log(s)
s2 = cdf["C_CO2 in ppm"]
ax1.plot(t, s, "--", lw=2)
ax2.plot(t, s2, ".-", lw=2)
ax1.set_xlabel("Messzeit $t$ in $hh:mm$")
ax1.xaxis.set_major_formatter(xfmt)
ax1.set_ylabel("$\\mathrm{ln}\\left[\\Delta C_{\\mathrm{CO_2}}(t)\\cdot \\left\\langle\\Delta C_{\\mathrm{CO_2},0}\\right\\rangle^{-1}\\right]$")
ax1.set_ylim(-2, 0)
ax1.set_yticks([-2, -1, 0])
ax2.set_ylabel("$C_{\\mathrm{CO_2},\\mathrm{BG}}\\left(t\\right)$")
ax2.set_ylim(0, 1000)
ax2.set_yticks([0, 300, 400, 500, 1000])
plt.grid(True)
tikzplotlib.save("lineardecayMeas.tex")
Traceback
File "<ipython-input-40-642a58692fcc>", line 1, in <module>
a.mean_curve(pltsave = True)
File "D:\Users\sauerswa\wichtige Ordner\sauerswa\Codes\Python\Recirculation-main\post_processing_DRK_recirculation.py", line 785, in mean_curve
tikzplotlib.save("lineardecayMeas.tex")
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_save.py", line 261, in save
code = get_tikz_code(*args, filepath=filepath, **kwargs)
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_save.py", line 210, in get_tikz_code
data, content = _recurse(data, figure)
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_save.py", line 349, in _recurse
data, children_content = _recurse(data, child)
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_save.py", line 365, in _recurse
data, cont = _line2d.draw_line2d(data, child)
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_line2d.py", line 99, in draw_line2d
c, axis_options = _table(obj, data)
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_line2d.py", line 241, in _table
xdata = [date.strftime("%Y-%m-%d %H:%M") for date in xdata]
File "C:\ProgramData\Anaconda3\envs\py37e1c1\lib\site-packages\tikzplotlib\_line2d.py", line 241, in <listcomp>
xdata = [date.strftime("%Y-%m-%d %H:%M") for date in xdata]
AttributeError: 'int' object has no attribute 'strftime'
I hope I haven't missed an already open issue regarding this.
Kind regards and thanks for any help
Cannot reproduce:
NameError: name 'mega_cdf' is not defined
Note that the M in MWE stands for minimal. Always trim down the code as much as possible; this way I can more easily reproduce the error, and maybe even include it as a test.
Closing for lack of feedback. Feel free to reopen with a complete, minimal example.