1

Is it possible to create an x-y Plot with addplot table where the x-axis entries are not shown, but instead text can be inserted for each one? This is because I have a file containing bonds and I'd like to write CH instead of 1 CN instad of 2,... The legend is already used to describe the different data sets. Of course I could write a separate "legend" in which I'd define 1=CH, 2=CN, but I have the feeling it should be possible to rename the axis entries. However I have not found anything of that sort so far.

Here is the code:

\begin{tikzpicture}
\begin{axis} [xlabel = {Bond}, ylabel={Länge in \si{\angstrom}}, xmin= {0}, xmax={14}, legend style={legend pos=  outer north east}]

\addplot [blue, only marks, mark=x, legend entry= {6-31G(d,p)}] table [x expr=\thisrowno{0}, y expr=\thisrowno{2}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [green , only marks, mark=x, legend entry= {6-311G(d,p)}] table [x expr=\thisrowno{0}, y expr=\thisrowno{5}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [purple, only marks, mark=x, legend entry={cc-pVDZ}] table [x expr=\thisrowno{0}, y expr=\thisrowno{8}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [black, only marks, mark=x, legend entry={cc-pVTZ}] table [x expr=\thisrowno{0}, y expr=\thisrowno{11}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [pink, only marks, mark=x, legend entry={cc-pVDZ?}] table [x expr=\thisrowno{0}, y expr=\thisrowno{14}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [yellow, only marks, mark=x, legend entry={SVP}] table [x expr=\thisrowno{0}, y expr=\thisrowno{17}, header=true] {plot/raw/length/13RHF.txt}; 
 \addplot [orange, only marks, mark=x, legend entry={TZV}] table [x expr=\thisrowno{0}, y expr=\thisrowno{20}, header=true] {plot/raw/length/13RHF.txt}; 

\addplot [red, only marks, legend entry={GAFF}] table [x expr=\thisrowno{0}, y expr=\thisrowno{2}, header=true] {plot/raw/length/13GAFF.txt};
\addplot [red, only marks, mark=o, legend entry= {XXX} ] table[x expr=\thisrowno{0}, y expr=\thisrowno{2}, header=true] {plot/raw/length/XXX.txt}; 

\end{axis}
\end{tikzpicture}

the preamble uses apart from the regular tikz/pgfplots/pgfplotstable packages and the tikzexternal/pgfplotsexternal libraries:

\pgfplotsset{
    legend entry/.initial=,
    every axis plot post/.code={%
        \pgfkeysgetvalue{/pgfplots/legend entry}\tempValue
        \ifx\tempValue\empty
        \pgfkeysalso{/pgfplots/forget plot}%
        \else
        \expandafter\addlegendentry\expandafter{\tempValue}%
        \fi
    },
}
6
  • Hi, welcome. Have a look at xticklabels from table, e.g. tex.stackexchange.com/questions/63335/… – Torbjørn T. Aug 27 '17 at 6:57
  • Sorry, had not found that one. I'll have to change it a bit, but that helps me so much, that the rest should be no problem. But still: this way I cannot use the data files the way they currently are, because I have to name the columns in there. – Arbor Chaos Aug 27 '17 at 7:10
  • It's not immediately obvious how your datafiles look ... You can use e.g. xticklabels from table={file.dat}{[index]0} to use the first column for labels. – Torbjørn T. Aug 27 '17 at 7:12
  • my datafiles contain only numbers in columns separated by space (which is why I did not post one here, because I thought this would have no real information), this is why I'd like to name them individually. – Arbor Chaos Aug 27 '17 at 7:16
  • I was perhaps overthinking this, do you just need xticklabels={CH,CN,...}? – Torbjørn T. Aug 27 '17 at 7:28