Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding scientific notations and thousand separators in the axises #585

Open
alexgunsberg opened this issue May 13, 2023 · 0 comments
Open

Comments

@alexgunsberg
Copy link

I don't manage to avoid the scientific notation nor the thousand separators in the axises. Seems like tikzplotlib forces some settings that overwrite the global settings in the latex preamble. We should either be able to pass these variables in python in the save method or they should take after the global settings in the latex document.

here is my Python code:

#  plot the lines into one graph

sns.lineplot(x='year', y='c_pop30', data=c_t_pop30, ci=None)
sns.lineplot(x='year', y='t_pop30', data=c_t_pop30, ci=None)
plt.legend(labels=['control', 'treatment'], facecolor='white')
plt.ylabel('Population')
plt.xlabel('Year')

#   add vertical lines
plt.axvline(1949)
plt.axvline(1990)

plt.ticklabel_format(useOffset=False, style='plain')

#   export to latex
tikzplotlib.save(r"/Users/alexgunsberg/Library/Mobile Documents/com~apple~CloudDocs/Hanken/Courses/Urban Economics/problem_set/manuscript/src/figs/fig3c.tex")

and this is how it looks in python:
expected

this is how it turns out in latex:
output

here's the latex the code that was saved by tikzplotlib

% This file was created with tikzplotlib v0.10.1.
\begin{tikzpicture}

\definecolor{chocolate2267451}{RGB}{226,74,51}
\definecolor{dimgray85}{RGB}{85,85,85}
\definecolor{gainsboro229}{RGB}{229,229,229}
\definecolor{lightgray204}{RGB}{204,204,204}
\definecolor{steelblue52138189}{RGB}{52,138,189}

\begin{axis}[
axis background/.style={fill=gainsboro229},
axis line style={white},
legend cell align={left},
legend style={
  fill opacity=0.8,
  draw opacity=1,
  text opacity=1,
  at={(0.03,0.97)},
  anchor=north west,
  draw=lightgray204
},
tick align=outside,
tick pos=left,
x grid style={white},
xlabel=\textcolor{dimgray85}{Year},
xmajorgrids,
xmin=1914.85, xmax=2006.15,
xtick style={color=dimgray85},
y grid style={white},
ylabel=\textcolor{dimgray85}{Population},
ymajorgrids,
ymin=-625675, ymax=22581575,
ytick style={color=dimgray85}
]
\addplot [semithick, chocolate2267451]
table {%
1919 12354098
1925 13558414
1933 15132396
1939 16334090
1950 16138726
1960 19809000
1970 20720800
1980 21305000
1988 20637600
1992 21526700
2002 21475777
};
\addlegendentry{control}
\addplot [semithick, steelblue52138189]
table {%
1919 429200
1925 451000
1933 484500
1939 575805
1950 787700
1960 797800
1970 815100
1980 882200
1988 833800
1992 866100
2002 852186
};
\addlegendentry{treatment}
\addplot [semithick, chocolate2267451, forget plot]
table {%
1949 -625675
1949 22581575
};
\addplot [semithick, chocolate2267451, forget plot]
table {%
1990 -625675
1990 22581575
};
\end{axis}

\end{tikzpicture}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant