-
-
Notifications
You must be signed in to change notification settings - Fork 238
tex_relative_path_to_data makes slashes in Windows style, which is not accepted by LaTeX. #509
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
Comments
I am also not entirely sure of how this is supposed to behave. It seems like the option import numpy as np
import matplotlib.pyplot as plt
import tikzplotlib
plt.imshow(np.random.randn(20,20))
tikzplotlib.save('./data/test.tex', tex_relative_path_to_data='plots', override_externals=True) Doing so, will save all files to a sub directory called Regarding the issue with slashes, I cannot replicate the same behaviour, for me the above code yields correctly: % This file was created by tikzplotlib v0.9.8.
\begin{tikzpicture}
\begin{axis}[
tick align=outside,
tick pos=left,
x grid style={white!69.0196078431373!black},
xmin=-0.5, xmax=19.5,
xtick style={color=black},
y dir=reverse,
y grid style={white!69.0196078431373!black},
ymin=-0.5, ymax=19.5,
ytick style={color=black}
]
\addplot graphics [includegraphics cmd=\pgfimage,xmin=-0.5, xmax=19.5, ymin=19.5, ymax=-0.5] {plots/data/test-000.png};
\end{axis}
\end{tikzpicture} |
Thanks @Blubbaa ! Will try it out next time I need to generate tikz images :) Strange that this error does not occur with you ... Your code generates for me:
Maybe I have configured my Python wrongly. Both running the code in a Jupyter notebook and in the PyCharm console results in the above... |
Ok, I did some investigations, it seems I encountered this issue before and just couldn't remember 😄 There was an open PR (#473) some time ago, which proposed to fix the problem here: tikzplotlib/src/tikzplotlib/_files.py Lines 38 to 43 in 15f0bfc
by adding some string replacement for Windows paths. Back then I have manually edited the local source from tikzplotlib and added this line in L42: # FIX: for windows relative paths (see https://github.com/nschloe/tikzplotlib/pull/473)
rel_filepath = str(rel_filepath).replace('\\', '/') It seems like that this should have been fixed already, but apparently is not. |
I'll look at it later. |
I believe the support for .dat files was forgotten in the fix. Instead of tikzplotlib/src/tikzplotlib/_line2d.py Lines 291 to 295 in 1e30229
posix_filepath = rel_filepath.as_posix() should also be used instead. I am not sure if there are any other similar issues with different styles.
Don't know if I should open a new issue or just reuse the old one. |
Hi,
When I give an argument to
tex_relative_path_to_data
, the slashes in the .tex-file are in Windows style but LaTeX does not accept them. Would be good if they are these '/' also for Windows PCs.Furthermore, I have no idea why there is
images/images
in the path. I think it should be there only once.Here you find:
images
exists in the folder where you run the code),Thanks for any suggestions besides manually adjusting the path in each image!
Isabell
The text was updated successfully, but these errors were encountered: