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

Does not work with --output-directory with either contour gnuplot or contour lua. #464

Open
ghost opened this issue Jul 7, 2023 · 10 comments

Comments

@ghost
Copy link

ghost commented Jul 7, 2023

MWE

\documentclass[10pt]{book}
\usepackage{shellesc}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[title={$x \exp(-x^2-y^2)$},xlabel=$x$, ylabel=$y$,small,]
  \addplot3 [
contour gnuplot,
domain=-2:2,
domain y=-1.3:1.3,
] {exp(-x^2-y^2)*x};
\end{axis}
\end{tikzpicture}
\end{document}

Compile with

lualatex --shell-escape --output-directory='aux/' test-pgfplots.tex

broken with the following error:

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-pgfplots_contourtmp0.script'


! Package pgfplots Error: sorry, plot file{test-pgfplots_contourtmp0.table} cou
ld not be opened.

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.14 ] {exp(-x^2-y^2)*x};

Compile with:

lualatex --shell-escape  test-pgfplots.tex

works.

It seems to be working with more low-level TikZ plots. I.e., the following works:

\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\end{tikzpicture}

This can be worked aroun, sort of, by setting:

\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=auctex-aux/]

But this is very-very slow, and requires a hardcoded prefix=<...> in the file.

@muzimuzhi
Copy link
Member

Works find here, with latest TeX Live 2023 and gnuplot 5.4.8.

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-pgfplots_contourtmp0.script'

These were thrown by gnuplot, thus not the fault of LaTeX, including pgfplots package. I find a similar ticket in gnuplot's bug tracker (https://sourceforge.net/p/gnuplot/bugs/2193/), which was solved by setting a utf8 locale.

@muzimuzhi muzimuzhi changed the title Does not work with --output-directory. contour gnuplot does not work with --output-directory. Jul 7, 2023
@ghost
Copy link
Author

ghost commented Jul 7, 2023

What is the actual version of lualatex? I can reproduce this reliably without gnuplot:

This is LuaHBTeX, Version 1.17.0 (TeX Live 2023 on Slackware)
Development id: 7581

Execute  'luahbtex --credits'  for credits and version details.

There is NO warranty. Redistribution of this software is covered by
the terms of the GNU General Public License, version 2 or (at your option)
any later version. For more information about these matters, see the file
named COPYING and the LuaTeX source.

LuaTeX is Copyright 2022 Taco Hoekwater and the LuaTeX Team.
\documentclass[10pt]{book}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[title={$x \exp(-x^2-y^2)$},xlabel=$x$, ylabel=$y$,small,]
  \addplot3 [
contour lua,
domain=-2:2,
domain y=-1.3:1.3,
] {exp(-x^2-y^2)*x};
\end{axis}
\end{tikzpicture}
\end{document}
Package pgfplots notification 'compat/show suggested version=true': document ha
s been generated with the most recent feature set (\pgfplotsset{compat=1.18}).

[\directlua]:1: module 'test-pgfplots_contourtmp0' not found:
	no field package.preload['test-pgfplots_contourtmp0']
	[kpse lua searcher] file not found: 'test-pgfplots_contourtmp0'
stack traceback:
	[C]: in function 'require'
	[\directlua]:1: in main chunk.
\pgfplotsplothandlersurveyend ...ur external/cmd}}
                                                  \else \pgfplots@error {Cal...

l.11 ] {exp(-x^2-y^2)*x};

@ghost ghost changed the title contour gnuplot does not work with --output-directory. Does not work with --output-directory with either contour gnuplot or contour lua. Jul 7, 2023
@muzimuzhi
Copy link
Member

What is the actual version of lualatex?

The same as yours,

This is LuaTeX, Version 1.17.0 (TeX Live 2023)
Development id: 7581

With contour lua I can reproduce the problem. Doubt if these two have the same cause.

@muzimuzhi
Copy link
Member

muzimuzhi commented Jul 7, 2023

This fixes the case using contour lua with --output-directory for me (relevent code was introduced in 7f99e13):

diff --git a/tex/generic/pgfplots/libs/tikzlibrarypgfplots.contourlua.code.tex b/tex/generic/pgfplots/libs/tikzlibrarypgfplots.contourlua.code.tex
index f782101..7b3d9a1 100644
--- a/tex/generic/pgfplots/libs/tikzlibrarypgfplots.contourlua.code.tex
+++ b/tex/generic/pgfplots/libs/tikzlibrarypgfplots.contourlua.code.tex
@@ -50,7 +50,7 @@
 					end;
 					yvaries = \if 0\ordering 'x'\else 'y'\fi;
 					yvaries = (yvaries == 'y');
-					infile = io.open(\"\infile\", \"r\");
+					infile = io.open(kpse.find_file(\"\infile\"), \"r\");
 					outfile = io.open(\"\outfile\", \"w\");
 					mesh = PrepcMesh.new(yvaries, nblocks, nlines, copylines, infile, outfile);
 					\ifpgfplotsplothandlercontour@corners

@muzimuzhi
Copy link
Member

muzimuzhi commented Jul 7, 2023

@lockywolf Can you reproduce the original problem (using contour gnuplot and --output-directory) with simpler gnuplot plot, like the first example in pgfmanual (v3.1.10), sec.
22.6 "Plotting a Function Using Gnuplot" (https://tikz.dev/tikz-plots#sec-22.6)?

Example excerpted from pgfmanual sec. 22.6

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[domain=0:4]
  \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);

  \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
  \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};

  \draw[color=red]    plot[id=x]   function{x}           node[right] {$f(x) =x$};
  \draw[color=blue]   plot[id=sin] function{sin(x)}      node[right] {$f(x) = \sin x$};
  \draw[color=orange] plot[id=exp] function{0.05*exp(x)} node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}

Update:

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-pgfplots_contourtmp0.script'

These were thrown by gnuplot, thus not the fault of LaTeX, including pgfplots package.

Also the .script file contains no degree sign... Wired.

@ghost
Copy link
Author

ghost commented Jul 7, 2023

Your patch does not affect my setup, seemingly.
I am seeing the same error (lua.

s been generated with the most recent feature set (\pgfplotsset{compat=1.18}).

[\directlua]:1: module 'test-pgfplots_contourtmp0' not found:
	no field package.preload['test-pgfplots_contourtmp0']
	[kpse lua searcher] file not found: 'test-pgfplots_contourtmp0'
	[kpse C searcher] file not found: 'test-pgfplots_contourtmp0'
stack traceback:
	[C]: in function 'require'
	[\directlua]:1: in main chunk.
\pgfplotsplothandlersurveyend ...ur external/cmd}}
                                                  \else \pgfplots@error {Cal...

l.11 ] {exp(-x^2-y^2)*x};
                       
? x

@muzimuzhi

The answer to the second question is also negative

[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-gnuplot.x.gnuplot'



Package pgf Warning: Plot data file `test-gnuplot.x.table' not found. on input 
line 11.

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-gnuplot.sin.gnuplot'


Package pgf Warning: Plot data file `test-gnuplot.sin.table' not found. on inpu
t line 12.

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-gnuplot.exp.gnuplot'


Package pgf Warning: Plot data file `test-gnuplot.exp.table' not found. on inpu
t line 13.

I will test with the latest gnuplot.

@ghost
Copy link
Author

ghost commented Jul 7, 2023

line 0: warning: iconv failed to convert degree sign
line 0: Cannot load input from 'test-pgfplots_contourtmp0.script'

These were thrown by gnuplot, thus not the fault of LaTeX, including pgfplots package.

Also the .script file contains no degree sign... Wired.

gnuplot is printing this warning when just launched.

lockywolf@laptop:/tmp/mwe>gnuplot 

	G N U P L O T
	Version 5.4 patchlevel 8    last modified 2023-06-01

	Copyright (C) 1986-1993, 1998, 2004, 2007-2023
	Thomas Williams, Colin Kelley and many others

	gnuplot home:     http://www.gnuplot.info
	faq, bugs, etc:   type "help FAQ"
	immediate help:   type "help"  (plot window: hit 'h')
warning: iconv failed to convert degree sign

Terminal type is now 'qt'

@ghost
Copy link
Author

ghost commented Jul 7, 2023

./configure \
  --prefix=/usr \
  --mandir=/usr/man \
  --infodir=/usr/info \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --with-gd \
  --with-caca \
  --with-qt=qt5 \
  --without-libcerf \
  --with-texdir=/usr/share/texmf-dist/tex/latex/gnuplot \
  --datadir=/usr/share/gnuplot \
  --with-readline=builtin \

@muzimuzhi
Copy link
Member

Works find here, [...]

I know why I can't reproduce it before: there existed *.table from previous run without --output-directory in current working directory.

It seems the call to gnuplot doesn't take value of --output-directory into consideration, see this question posted in 2013 https://tex.stackexchange.com/q/109331.

@ghost
Copy link
Author

ghost commented Jul 7, 2023

I suspect that the lua issue is the same issue then. The SO question seems to give a working solution to this issue, given that the value of --output-directory is available in runtime. Could it be added to the pgfplots code somewhere?

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

No branches or pull requests

1 participant