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

axis values not showing when using .save() #584

Open
alexgunsberg opened this issue May 12, 2023 · 2 comments
Open

axis values not showing when using .save() #584

alexgunsberg opened this issue May 12, 2023 · 2 comments

Comments

@alexgunsberg
Copy link

alexgunsberg commented May 12, 2023

sns.lineplot(data = c_t_pop30, x="year", y="dif_growth")
plt.axvline(1949)
plt.axvline(1990)

tikzplotlib.save(r"/Users/a/Library/Mobile Documents/com~apple~CloudDocs/Courses/Economics/problem_set/manuscript/src/figs/fig4c_alone.tex")

Python shows the values for both axes, as expected
output

Actual output in latex
fail_a

Here is the latex code that was saved:

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

\definecolor{darkslategray38}{RGB}{38,38,38}
\definecolor{lavender234234242}{RGB}{234,234,242}
\definecolor{steelblue31119180}{RGB}{31,119,180}

\begin{axis}[
axis background/.style={fill=lavender234234242},
axis line style={white},
tick align=outside,
x grid style={white},
xlabel=\textcolor{darkslategray38}{year},
xmajorgrids,
xmajorticks=false,
xmin=1921.15, xmax=2005.85,
xtick style={color=darkslategray38},
y grid style={white},
ylabel=\textcolor{darkslategray38}{dif\_growth},
ymajorgrids,
ymajorticks=false,
ymin=-0.118489124518529, ymax=0.0844196238924438,
ytick style={color=darkslategray38}
]
\addplot [semithick, steelblue31119180]
table {%
1925 -0.0213444461404777
1933 -0.0566859111009346
1939 0.0751964989646723
1950 0.0192261391483122
1960 -0.109265999590757
1970 -0.0633964941647206
1980 -0.0537741982727188
1988 -0.00858158243166562
1992 -0.000585163199995131
2002 0.00798771051790126
};
\addplot [semithick, steelblue31119180]
table {%
1949 -0.118489124518529
1949 0.0844196238924437
};
\addplot [semithick, steelblue31119180]
table {%
1990 -0.118489124518529
1990 0.0844196238924437
};
\end{axis}

\end{tikzpicture}

@alexgunsberg
Copy link
Author

Apparently this bug is only present with some matplotlib styles. I was using Seaborn the default didn't show the axises, but when I changed the style to ggplot it solved this part of the issue:

#   setting plot style
import matplotlib as mpl

plt.close()
mpl.rcParams.update(mpl.rcParamsDefault)
plt.style.use("ggplot") 

@DoctorDinosaur
Copy link

Same issue here, it's not working nice with seaborn. I'm just manually updating the generated code.

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

2 participants