2

I have generated using gnuplot a TikZ TeX script, and - unlike a simple plot sin(x)- it does not compile. What am I exactly missing?

The error message I receive when running pdflatex is

! Package pgfkeys Error: I do not know the key '/tikz/gnuplot' and I am going t
o ignore it. Perhaps you misspelled it.

My entire test file is:

\documentclass[12pt]{article}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\author{Rodion ``rodde'' Efremov}
\title{Trying to get the gnuplot generated TikZ TeX to compile}
\maketitle

\begin{tikzpicture}[gnuplot]
%% generated with GNUPLOT 5.0p5 (Lua 5.2; terminal rev. 99, script rev. 100)
%% Thu Mar  9 13:27:03 2017
\tikzset{every node/.append style={font={Verdana\fontsize{12pt}{14.4pt}\selectfont}}}
\path (0.000,0.000) rectangle (850.000,500.000);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetdashtype{gp dt solid}
\gpsetlinewidth{1.00}
\draw[gp path] (1.806,2.088)--(1.986,2.088);
\draw[gp path] (849.336,2.088)--(849.156,2.088);
\node[gp node right,font={Monospaced},bold 14] at (1.585,2.088) {$0$};
\draw[gp path] (1.806,84.888)--(1.986,84.888);
\draw[gp path] (849.336,84.888)--(849.156,84.888);
\node[gp node right,font={Monospaced},bold 14] at (1.585,84.888) {$200$};
\draw[gp path] (1.806,167.688)--(1.986,167.688);
\draw[gp path] (849.336,167.688)--(849.156,167.688);
\node[gp node right,font={Monospaced},bold 14] at (1.585,167.688) {$400$};
\draw[gp path] (1.806,250.489)--(1.986,250.489);
\draw[gp path] (849.336,250.489)--(849.156,250.489);
\node[gp node right,font={Monospaced},bold 14] at (1.585,250.489) {$600$};
\draw[gp path] (1.806,333.289)--(1.986,333.289);
\draw[gp path] (849.336,333.289)--(849.156,333.289);
\node[gp node right,font={Monospaced},bold 14] at (1.585,333.289) {$800$};
\draw[gp path] (1.806,416.089)--(1.986,416.089);
\draw[gp path] (849.336,416.089)--(849.156,416.089);
\node[gp node right,font={Monospaced},bold 14] at (1.585,416.089) {$1000$};
\draw[gp path] (1.806,498.889)--(1.986,498.889);
\draw[gp path] (849.336,498.889)--(849.156,498.889);
\node[gp node right,font={Monospaced},bold 14] at (1.585,498.889) {$1200$};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (78.854,1.867) {Binary};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (155.902,1.867) {Binomial};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (232.951,1.867) {Fibonacci};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (309.999,1.867) {Pairing};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (387.047,1.867) {Dial's};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (464.095,1.867) {AVL-tree};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (541.143,1.867) {vEB-tree};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (618.191,1.867) {B-tree, 32};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (695.240,1.867) {B-tree, 64};
\node[gp node left,rotate=-45,font={Monospaced},bold 14] at (772.288,1.867) {B-tree, 128};
\draw[gp path] (1.806,498.889)--(1.806,2.088)--(849.336,2.088)--(849.336,498.889)--cycle;
\node[gp node center,rotate=-270,font={Verdana\fontsize{12pt}{14.4pt}\selectfont}] at (0.295,250.488) {Duration in milliseconds};
\node[gp node center,font={Verdana\fontsize{12pt}{14.4pt}\selectfont}] at (425.571,499.444) {Other integer heap performance};
\node[gp node right,font={Verdana\fontsize{12pt}{14.4pt}\selectfont}] at (847.609,498.524) {Unidexed};
\gpfill{rgb color={0.333,0.333,1.000}} (847.830,498.432)--(848.894,498.432)--(848.894,498.617)--(847.830,498.617)--cycle;
\draw[gp path] (847.830,498.432)--(848.894,498.432)--(848.894,498.616)--(847.830,498.616)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (50.924,2.088)--(68.261,2.088)--(68.261,96.067)--(50.924,96.067)--cycle;
\draw[gp path] (50.924,2.088)--(50.924,96.066)--(68.260,96.066)--(68.260,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (127.972,2.088)--(145.309,2.088)--(145.309,95.653)--(127.972,95.653)--cycle;
\draw[gp path] (127.972,2.088)--(127.972,95.652)--(145.308,95.652)--(145.308,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (205.021,2.088)--(222.357,2.088)--(222.357,102.691)--(205.021,102.691)--cycle;
\draw[gp path] (205.021,2.088)--(205.021,102.690)--(222.356,102.690)--(222.356,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (282.069,2.088)--(299.406,2.088)--(299.406,98.965)--(282.069,98.965)--cycle;
\draw[gp path] (282.069,2.088)--(282.069,98.964)--(299.405,98.964)--(299.405,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (359.117,2.088)--(376.454,2.088)--(376.454,75.781)--(359.117,75.781)--cycle;
\draw[gp path] (359.117,2.088)--(359.117,75.780)--(376.453,75.780)--(376.453,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (436.165,2.088)--(453.502,2.088)--(453.502,79.507)--(436.165,79.507)--cycle;
\draw[gp path] (436.165,2.088)--(436.165,79.506)--(453.501,79.506)--(453.501,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (513.213,2.088)--(530.550,2.088)--(530.550,418.574)--(513.213,418.574)--cycle;
\draw[gp path] (513.213,2.088)--(513.213,418.573)--(530.549,418.573)--(530.549,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (590.261,2.088)--(607.598,2.088)--(607.598,78.679)--(590.261,78.679)--cycle;
\draw[gp path] (590.261,2.088)--(590.261,78.678)--(607.597,78.678)--(607.597,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (667.310,2.088)--(684.647,2.088)--(684.647,85.717)--(667.310,85.717)--cycle;
\draw[gp path] (667.310,2.088)--(667.310,85.716)--(684.646,85.716)--(684.646,2.088)--cycle;
\gpfill{rgb color={0.333,0.333,1.000}} (744.358,2.088)--(761.695,2.088)--(761.695,79.093)--(744.358,79.093)--cycle;
\draw[gp path] (744.358,2.088)--(744.358,79.092)--(761.694,79.092)--(761.694,2.088)--cycle;
\node[gp node right,font={Verdana\fontsize{12pt}{14.4pt}\selectfont}] at (847.609,498.154) {Indexed};
\gpfill{rgb color={0.957,0.863,0.259}} (847.830,498.062)--(848.894,498.062)--(848.894,498.247)--(847.830,498.247)--cycle;
\draw[gp path] (847.830,498.062)--(848.894,498.062)--(848.894,498.246)--(847.830,498.246)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (70.186,2.088)--(87.523,2.088)--(87.523,90.271)--(70.186,90.271)--cycle;
\draw[gp path] (70.186,2.088)--(70.186,90.270)--(87.522,90.270)--(87.522,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (147.234,2.088)--(164.571,2.088)--(164.571,101.863)--(147.234,101.863)--cycle;
\draw[gp path] (147.234,2.088)--(147.234,101.862)--(164.570,101.862)--(164.570,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (224.283,2.088)--(241.619,2.088)--(241.619,110.557)--(224.283,110.557)--cycle;
\draw[gp path] (224.283,2.088)--(224.283,110.556)--(241.618,110.556)--(241.618,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (301.331,2.088)--(318.668,2.088)--(318.668,105.175)--(301.331,105.175)--cycle;
\draw[gp path] (301.331,2.088)--(301.331,105.174)--(318.667,105.174)--(318.667,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (378.379,2.088)--(395.716,2.088)--(395.716,91.099)--(378.379,91.099)--cycle;
\draw[gp path] (378.379,2.088)--(378.379,91.098)--(395.715,91.098)--(395.715,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (455.427,2.088)--(472.764,2.088)--(472.764,93.583)--(455.427,93.583)--cycle;
\draw[gp path] (455.427,2.088)--(455.427,93.582)--(472.763,93.582)--(472.763,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (532.475,2.088)--(549.812,2.088)--(549.812,446.726)--(532.475,446.726)--cycle;
\draw[gp path] (532.475,2.088)--(532.475,446.725)--(549.811,446.725)--(549.811,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (609.524,2.088)--(626.860,2.088)--(626.860,79.093)--(609.524,79.093)--cycle;
\draw[gp path] (609.524,2.088)--(609.524,79.092)--(626.859,79.092)--(626.859,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (686.572,2.088)--(703.909,2.088)--(703.909,89.857)--(686.572,89.857)--cycle;
\draw[gp path] (686.572,2.088)--(686.572,89.856)--(703.908,89.856)--(703.908,2.088)--cycle;
\gpfill{rgb color={0.957,0.863,0.259}} (763.620,2.088)--(780.957,2.088)--(780.957,84.061)--(763.620,84.061)--cycle;
\draw[gp path] (763.620,2.088)--(763.620,84.060)--(780.956,84.060)--(780.956,2.088)--cycle;
\draw[gp path] (1.806,498.889)--(1.806,2.088)--(849.336,2.088)--(849.336,498.889)--cycle;
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.806cm}{2.088cm}}{\pgfpoint{849.336cm}{498.889cm}}
\end{tikzpicture}
%% gnuplot variables

\end{document}

The above snippet was generated by the following gnuplot script:

set terminal tikz size 850,500 enhanced font 'Verdana,12' persist
set output "integer_heap_benchmark_other_tikz.tex"
set boxwidth 0.9 absolute
set ylabel "Duration in milliseconds" #font "Arial 14"
set tics font "Monospaced,bold 14"
set style fill solid 1.00 border lt -1
set key inside right top vertical Right noreverse noenhanced autotitle nobox 
set style histogram cluster gap 1 title textcolor lt -1
set minussign
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45 autojustify
set xtics norangelimit
set xtics    ()
set title "Other integer heap performance"
set yrange [0:*]
set style line 1 lt 1 lc rgb "#000000"
set style line 2 lt 2 lc rgb "green"
plot 'integer_heap_benchmark_other.dat' using 2:xtic(1) linecolor rgb "#5555ff" title col, \
        '' using 3:xtic(1) linecolor rgb "#f4dc42" title col, \
        '' using 4:xtic(1) title col
13
  • 1
    First of all it is always a good idea to cite the error you get. Plus people here are generally not happy about code hosted externally, that data might not be available in the future.
    – daleif
    Mar 9, 2017 at 12:17
  • @daleif Fair enough. I will try to improve my question asap.
    – coderodde
    Mar 9, 2017 at 12:20
  • @daleif I added the error message. How should I go about presenting my code?
    – coderodde
    Mar 9, 2017 at 12:23
  • Do the same thing. Paste it into the editor here. Tip: if you mark the code and click CTRL-k then the editor will indent this region 4 spaces displaying it as code (I think the editor controls an also do this).
    – daleif
    Mar 9, 2017 at 12:28
  • The error indicate the gnuplot key/style is unknown. I have no idea what it should be.
    – daleif
    Mar 9, 2017 at 12:28

1 Answer 1

1

(In case anyone else wonders how to make this work.)

Take a simpler Gnuplot script such as this:

set terminal tikz size 5,4 createstyle
set output "demo.tex"
plot sin(x)

Compared to your script, there is one key thing that is added:

createstyle

That option means that some additional files are created, as seen from the terminal output shown below. These files contain the style definitions that are used in the TikZ code.

plots$ ls
tikzout.gnu
plots$ gnuplot tikzout.gnu 
plots$ ls
demo.tex                     gnuplot-lua-tikz.sty  t-gnuplot-lua-tikz.tex
gnuplot-lua-tikz-common.tex  gnuplot-lua-tikz.tex  tikzout.gnu

The various files contains code for LaTeX (gnuplot-lua-tikz.sty), ConTeXt (t-gnuplot-lua-tikz.tex) and plain TeX (gnuplot-lua-tikz.tex).

A minimal LaTeX document for using the Gnuplot output will then be

\documentclass[border=5mm]{standalone}
\usepackage{gnuplot-lua-tikz}
\begin{document}
\input{demo}
\end{document}

The generated gnuplot-lua-tikz loads the TikZ package (hence \usepackage{tikz} not required), and defines all the necessary styles. The output of this is

output of code

(Not the prettiest plot, but this was just a demonstration anyway.)

For reference, the demo.tex file generated by Gnuplot looks like the following.

\begin{tikzpicture}[gnuplot]
%% generated with GNUPLOT 5.0p3 (Lua 5.1; terminal rev. 99, script rev. 100)
%% Sat 25 Nov 2017 07:02:18 PM CET
\path (0.000,0.000) rectangle (5.000,4.000);
\gpcolor{color=gp lt color border}
\gpsetlinetype{gp lt border}
\gpsetdashtype{gp dt solid}
\gpsetlinewidth{1.00}
\draw[gp path] (1.196,0.616)--(1.376,0.616);
\draw[gp path] (4.447,0.616)--(4.267,0.616);
\node[gp node right] at (1.012,0.616) {$-1$};
\draw[gp path] (1.196,0.918)--(1.376,0.918);
\draw[gp path] (4.447,0.918)--(4.267,0.918);
\node[gp node right] at (1.012,0.918) {$-0.8$};
\draw[gp path] (1.196,1.219)--(1.376,1.219);
\draw[gp path] (4.447,1.219)--(4.267,1.219);
\node[gp node right] at (1.012,1.219) {$-0.6$};
\draw[gp path] (1.196,1.520)--(1.376,1.520);
\draw[gp path] (4.447,1.520)--(4.267,1.520);
\node[gp node right] at (1.012,1.520) {$-0.4$};
\draw[gp path] (1.196,1.822)--(1.376,1.822);
\draw[gp path] (4.447,1.822)--(4.267,1.822);
\node[gp node right] at (1.012,1.822) {$-0.2$};
\draw[gp path] (1.196,2.124)--(1.376,2.124);
\draw[gp path] (4.447,2.124)--(4.267,2.124);
\node[gp node right] at (1.012,2.124) {$0$};
\draw[gp path] (1.196,2.425)--(1.376,2.425);
\draw[gp path] (4.447,2.425)--(4.267,2.425);
\node[gp node right] at (1.012,2.425) {$0.2$};
\draw[gp path] (1.196,2.727)--(1.376,2.727);
\draw[gp path] (4.447,2.727)--(4.267,2.727);
\node[gp node right] at (1.012,2.727) {$0.4$};
\draw[gp path] (1.196,3.028)--(1.376,3.028);
\draw[gp path] (4.447,3.028)--(4.267,3.028);
\node[gp node right] at (1.012,3.028) {$0.6$};
\draw[gp path] (1.196,3.330)--(1.376,3.330);
\draw[gp path] (4.447,3.330)--(4.267,3.330);
\node[gp node right] at (1.012,3.330) {$0.8$};
\draw[gp path] (1.196,3.631)--(1.376,3.631);
\draw[gp path] (4.447,3.631)--(4.267,3.631);
\node[gp node right] at (1.012,3.631) {$1$};
\draw[gp path] (1.196,0.616)--(1.196,0.796);
\draw[gp path] (1.196,3.631)--(1.196,3.451);
\node[gp node center] at (1.196,0.308) {$-10$};
\draw[gp path] (2.009,0.616)--(2.009,0.796);
\draw[gp path] (2.009,3.631)--(2.009,3.451);
\node[gp node center] at (2.009,0.308) {$-5$};
\draw[gp path] (2.822,0.616)--(2.822,0.796);
\draw[gp path] (2.822,3.631)--(2.822,3.451);
\node[gp node center] at (2.822,0.308) {$0$};
\draw[gp path] (3.634,0.616)--(3.634,0.796);
\draw[gp path] (3.634,3.631)--(3.634,3.451);
\node[gp node center] at (3.634,0.308) {$5$};
\draw[gp path] (4.447,0.616)--(4.447,0.796);
\draw[gp path] (4.447,3.631)--(4.447,3.451);
\node[gp node center] at (4.447,0.308) {$10$};
\draw[gp path] (1.196,3.631)--(1.196,0.616)--(4.447,0.616)--(4.447,3.631)--cycle;
\node[gp node right] at (2.979,3.297) {sin(x)};
\gpcolor{rgb color={0.580,0.000,0.827}}
\draw[gp path] (3.163,3.297)--(4.079,3.297);
\draw[gp path] (1.196,2.944)--(1.229,2.673)--(1.262,2.380)--(1.295,2.077)--(1.327,1.776)%
  --(1.360,1.488)--(1.393,1.227)--(1.426,1.002)--(1.459,0.823)--(1.492,0.696)--(1.524,0.628)%
  --(1.557,0.620)--(1.590,0.674)--(1.623,0.787)--(1.656,0.953)--(1.689,1.168)--(1.721,1.421)%
  --(1.754,1.703)--(1.787,2.002)--(1.820,2.306)--(1.853,2.603)--(1.886,2.880)--(1.918,3.126)%
  --(1.951,3.332)--(1.984,3.488)--(2.017,3.589)--(2.050,3.630)--(2.083,3.610)--(2.115,3.530)%
  --(2.148,3.392)--(2.181,3.203)--(2.214,2.969)--(2.247,2.702)--(2.280,2.411)--(2.313,2.108)%
  --(2.345,1.806)--(2.378,1.517)--(2.411,1.252)--(2.444,1.023)--(2.477,0.839)--(2.510,0.707)%
  --(2.542,0.632)--(2.575,0.618)--(2.608,0.666)--(2.641,0.772)--(2.674,0.934)--(2.707,1.144)%
  --(2.739,1.394)--(2.772,1.674)--(2.805,1.971)--(2.838,2.276)--(2.871,2.573)--(2.904,2.853)%
  --(2.936,3.103)--(2.969,3.313)--(3.002,3.475)--(3.035,3.581)--(3.068,3.629)--(3.101,3.615)%
  --(3.133,3.540)--(3.166,3.408)--(3.199,3.224)--(3.232,2.995)--(3.265,2.730)--(3.298,2.441)%
  --(3.330,2.139)--(3.363,1.836)--(3.396,1.545)--(3.429,1.278)--(3.462,1.044)--(3.495,0.855)%
  --(3.528,0.717)--(3.560,0.637)--(3.593,0.617)--(3.626,0.658)--(3.659,0.759)--(3.692,0.915)%
  --(3.725,1.121)--(3.757,1.367)--(3.790,1.644)--(3.823,1.941)--(3.856,2.245)--(3.889,2.544)%
  --(3.922,2.826)--(3.954,3.079)--(3.987,3.294)--(4.020,3.460)--(4.053,3.573)--(4.086,3.627)%
  --(4.119,3.619)--(4.151,3.551)--(4.184,3.424)--(4.217,3.245)--(4.250,3.020)--(4.283,2.759)%
  --(4.316,2.471)--(4.348,2.170)--(4.381,1.867)--(4.414,1.574)--(4.447,1.303);
\gpcolor{color=gp lt color border}
\draw[gp path] (1.196,3.631)--(1.196,0.616)--(4.447,0.616)--(4.447,3.631)--cycle;
%% coordinates of the plot area
\gpdefrectangularnode{gp plot 1}{\pgfpoint{1.196cm}{0.616cm}}{\pgfpoint{4.447cm}{3.631cm}}
\end{tikzpicture}
%% gnuplot variables

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .