Дмитрий
Дмитрий

Reputation: 51

Tikz inside gnuplottex

Here is such a code.

\documentclass{standalone}
\usepackage[miktex]{gnuplottex}
\usepackage[utf8]{inputenc}
\begin{document}
    \begin{gnuplot}
        set terminal epslatex color
        set xrange [-4:4]
        set yrange [0:16]
        set xlabel '$x$'
        set ylabel '$y$'
        plot x**2 title '$y=x^2$'
    \end{gnuplot}
\end{document}

Is it possible to draw primitives using tikz in a coordinate system created by gnuplot, similar to pgfplots? For example, \draw (axis cs:0 , 0) -- (axis cs:1 , 1);

Upvotes: 0

Views: 443

Answers (1)

Eldrad
Eldrad

Reputation: 743

There are probably many ways of doing so, here is a solution using the tikzlibrary tikzmark, which puts a custom mark called "a" in the ylabel string (but which could also be placed by an arbitrary set label command). Your code was not compilable for me; one of the reasons is that the set terminal command has to be provided as an option to \begin{gnuplot} instead of inside the gnuplot code. Since you want to use tikz I would recommend to use the tikz terminal anyway.

\documentclass{standalone}
\usepackage{gnuplot-lua-tikz}
\usepackage{gnuplottex}
\usepackage[utf8]{inputenc}
\usetikzlibrary{tikzmark}

\begin{document}
 \begin{gnuplot}[terminal=tikz]
  set xrange [-4:4]
  set yrange [0:16]
  set xlabel '$x$'
  set ylabel '$\tikzmark{a}y$'
  plot x**2 title '$y=x^2$'
 \end{gnuplot}
    
An arrow going from the $y$ label to exactly here.\tikz[remember picture, overlay] \draw[<-, bend angle = 10, bend right] (0,0) to (pic cs:a);

\end{document}

enter image description here

Upvotes: 2

Related Questions