0

I am new to Tikz and hoping to use it's data visualization package, but the following simple test document fails to build;

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}

\begin{document}

\begin{tikzpicture} 
    \datavisualization [scientific axes, visualize as scatter]
    data [ read from file = kuboout18117.csv ];
\end{tikzpicture}
\end{document}

with error;

Package pgfkeys Error: I do not know the key '/pgf/data/read from file'
and I am going to ignore it. Perhaps you misspelled it.

Upon looking into documentation and existing posts, I am puzzled as to why this is happening!

The first few lines of the imported file are;

N , Gamma
2 , -0.00646673
3 , -0.00111146
4 , -3.1868e-05
5 , 0.000311116
6 , 0.000698315

which I thought seemed harmless enough.. Any assistance will be greatly appreciated!

2
  • 1
    is there any important reason you don't use the pgfplots package, which would make this much easier while at the same time offering far more options?
    – Timm
    Mar 21, 2017 at 21:56
  • @Timm since I have been impressed with TikZ upon my reading of it, I thought it would be nice to be able to use the Datavisualization side of it. However upon looking into it further, as you say, I could well be better off with the pgfplots package.
    – AlexD
    Mar 22, 2017 at 10:35

1 Answer 1

0

Ok, I rewrote your example to make it work in pgfplots and tried to set some basic settings, however I'd recommend you to study some examples as well as the pgfplots manual.

The resulting LaTeX code four your plot would be:

\documentclass{article}
\usepackage{tikz,pgfplots}
\usepackage{filecontents}

\begin{filecontents*}{kuboout18117.csv}
N, Gamma
2, -0.00646673
3, -0.00111146
4, -3.1868e-05
5, 0.000311116
6, 0.000698315
\end{filecontents*}

\begin{document}

\begin{tikzpicture} 
    \begin{axis}[
        scaled y ticks=false,
        y tick label style={
            /pgf/number format/fixed,
            /pgf/number format/fixed zerofill,
            /pgf/number format/precision=3,
            },
        ymin=-0.008, ymax=0.002,
        xmin=0, xmax=8,
        ]
        \addplot[only marks, mark=*] table[x=N, y=Gamma, col sep=comma] {kuboout18117.csv};
    \end{axis}
\end{tikzpicture}
\end{document}

with the visual result:

enter image description here

1
  • Thanks for that, I did have a play around yesterday with pgfplots and got some pleasing results, just need to tidy it up, but it does seem I can safely forget about TikZ Datavisualisation.
    – AlexD
    Mar 23, 2017 at 13:04

You must log in to answer this question.

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