Closed PRemmen closed 5 years ago
I try to create plots with hourly data for one year and and displaying the month on the x-axis. This is a minimal example of my python code:
import pandas as pd import numpy as np import matplotlib.pyplot as plt import tikzplotlib df_plot = pd.DataFrame(np.random.randn(8760, 1), columns=["simulation"]) df_plot.index = pd.date_range( start="2017-01-01 00:00:00+00:00", end="2017-12-31 23:00:00+00:00", freq="H" ) fig = plt.figure("Rohdaten FZJ") ax12 = fig.add_subplot(111) fig.subplots_adjust(bottom=0.1) ax12.plot(df_plot.index, df_plot["simulation"], label="Simulation") ax12.xaxis.set_major_locator(mdates.MonthLocator(interval=2)) ax12.xaxis.set_major_formatter(mdates.DateFormatter("%d-%m-%Y")) plt.gcf().autofmt_xdate() plt.tight_layout() tikzplotlib.save("Simulation.tikz") plt.savefig("Simulation.png", transparent=True)
This is the TeX Code I'm getting (I deleted all data except first and last entries for readability)
% This file was created by tikzplotlib v0.8.2. \begin{tikzpicture} \definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177} \begin{axis}[ tick align=outside, tick pos=left, x grid style={white!69.01960784313725!black}, xmin=736311.752083333, xmax=736713.20625, xtick style={color=black}, xtick={736330,736389,736450,736511,736573,736634,736695}, xticklabel style = {rotate=30.0}, xticklabels={01-01-2017,01-03-2017,01-05-2017,01-07-2017,01-09-2017,01-11-2017,01-01-2018}, y grid style={white!69.01960784313725!black}, ymin=-3.97578151025687, ymax=3.78882092720731, ytick style={color=black} ] \addplot [semithick, color0] table {% 736330 0.327795239881513 736330.041666667 -0.0747599113657556 ... 736694.875 0.111241323306133 736694.916666667 -0.237033632238238 736694.958333333 0.408593296674818 }; \end{axis} \end{tikzpicture}
I render the tikz image with:
\begin{figure}[ht] \centering \input{figures/.../Simulation.tikz} \caption{An example of a tikz diagram} \label{fig:example1} \end{figure}
in my main document I included:
\usepackage{tikz,pgfplots} \pgfplotsset{compat=newest} \usepgfplotslibrary{groupplots} \usepgfplotslibrary{dateplot} \usetikzlibrary{plotmarks, shapes, arrows, positioning, shadows, trees} \usetikzlibrary{external} \tikzexternalize[prefix=figures/tikz/tikz_]
Now, If I am comparing the .png result and the rendered .pdf (see screenshots) the rendered pdf has an exponent (10⁵) in the xaxis label.
png: pdf:
I do not want to have this exponent in my figure. What am I doing wrong?
Thanks for any help! :+1:
Update:
adding scaled x ticks=false, leads to the desired results. I'll close the issue.
tikzplotlib.save("Simulation.tikz", extra_axis_parameters=["scaled x ticks=false"])
I try to create plots with hourly data for one year and and displaying the month on the x-axis. This is a minimal example of my python code:
This is the TeX Code I'm getting (I deleted all data except first and last entries for readability)
I render the tikz image with:
in my main document I included:
Now, If I am comparing the .png result and the rendered .pdf (see screenshots) the rendered pdf has an exponent (10⁵) in the xaxis label.
png: pdf:
I do not want to have this exponent in my figure. What am I doing wrong?
Thanks for any help! :+1: