5

I want to set labels with manual anchors in my graphic to allow for reading the captions and am trying to apply everything I've read so far. I have an external file for data, given below. The problem is that the line starting with 'every node near coord/.append style' generates an error saying:

Package PGF Math Error: Unknown function `thisrow_unavailable_load_table_directly' (in 'thisrow_unavailable_load_table_directly')

Here I am, and blocked. Any help welcome. I have produced a MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,graphicx,pgfplots,siunitx}
\usepgfplotslibrary{units} 
\usepackage{pgfplotstable}
\pgfplotstableset{col sep=semicolon}
\pgfplotsset{compat=1.12}
\begin{filecontents}{aircraft.txt}
aircraft    mph knots   kph introduction    ancre
Boeing-247  188 160 303 1933    east
Douglas-DC3 207 180 333 1936    east
DC4 227 197 365 1942    east
Lockheed-049    313 271 504 1946    west
DC-6B   311 270 501 1947    east
DC-7C   359 312 578 1953    east
DC-8    588 510 946 1958    north
B707    570 495 917 1958    west
B747-100    554 481 892 1966    south
B747-300    567 493 912 1980    south
B747-400    570 495 917 1985    north
\end{filecontents}
\pgfplotstableread{aircraft.txt}{\aircraft}
\begin{document}
  \begin{figure}[ht]
  \centering
  \begin{tikzpicture}
    \begin{axis} [
     width=0.95\textwidth,
     xtick pos=left, x unit=m,   x unit prefix=k,
     ytick pos=left, y unit=m/h, y unit prefix=k, ylabel={Cruise speed},
     clip=false      ]
     \addplot+[
       nodes near coords, point meta=explicit symbolic,
       visualization depends on={value \thisrow{ancre}\as\myanchor},
       every node near coord/.append style={font=\tiny,anchor=\myanchor}
     ] table [x={introduction}, y={kph},meta={aircraft}] {\aircraft};
    \end{axis}
  \end{tikzpicture}
  \end{figure}
  \end{document}
  • If add table directly into addplot macro, and comment its call before tikzpicture, it works fine. Where and you have stored your table? Tray to complete your MWE so, that the table aircraft_speed.dat will be part of it. – Zarko Jan 5 '16 at 23:10
  • I've finally done the MWE, that was a difficult task, now I hope someone will help me ! – the world is not flat Jan 12 '16 at 11:25
2

It turns out there is a difference between preloaded table and inline table.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,graphicx,pgfplots,siunitx}
\usepgfplotslibrary{units} 
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\begin{filecontents}{aircraft.txt}
\end{filecontents}
\pgfplotstableread{aircraft.txt}{\aircraft}
\begin{document}
  \begin{figure}[ht]
  \centering
  \begin{tikzpicture}
    \begin{axis} [
     width=0.95\textwidth,
     xtick pos=left, x unit=m,   x unit prefix=k,
     ytick pos=left, y unit=m/h, y unit prefix=k, ylabel={Cruise speed},
     clip=false      ]
     \addplot+[
       nodes near coords, point meta=explicit symbolic,
       visualization depends on={value \thisrow{position}\as\myposition},
       every node near coord/.style={font=\tiny,\myposition}
     ] table [x={introduction}, y={kph},meta={aircraft}] {
       aircraft     mph knots kph introduction position
       Boeing-247   188 160   303 1933         below
       Douglas-DC3  207 180   333 1936         {below right}
       DC4          227 197   365 1942         right
       Lockheed-049 313 271   504 1946         left
       DC-6B        311 270   501 1947         right
       DC-7C        359 312   578 1953         right
       DC-8         588 510   946 1958         above
       B707         570 495   917 1958         left
       B747-100     554 481   892 1966         below
       B747-300     567 493   912 1980         below
       B747-400     570 495   917 1985         above
     };
    \end{axis}
  \end{tikzpicture}
  \end{figure}
\end{document}

Some comments

(As asked by @Zarko)

In pgfplotscoordprocessing.code.tex line 6345-6352 there is

% These macros are-unfortunately- not accessable here. And the
% worst is: error messages are impossible either because they are
% not executed... try to provide useful hints:
\def\thisrow##1{thisrow_unavailable_load_table_directly}%
\def\thisrowno##1{thisrowno_unavailable_load_table_directly}%
% this should work.
\def\getthisrow##1##2{\pgfplotstablegetelem{\coordindex}{##1}\of{#3}{##2}}%
\def\getthisrowno##1##2{\pgfplotstablegetelem{\coordindex}{[index]##1}\of{#3}{##2}}%

This is the only occurrence of the string in the error message. So we might guess that your document, for some reason regarding source of table, encountered these lines, and then stopped.

The author suggests us to use \getthisrow over \thisrow. However it is difficult, if possible, to use \getthisrow inside visualization depends on= since the parser of the latter needs \as. Until now this is all I can tell.

| improve this answer | |
  • I found the same (see my comment), however, I was not able to discover, what is going wrong, if table is not part of graph (is given as file). I still learning pgfplots and pgfplotstable ... – Zarko Jan 14 '16 at 4:09
  • @Zarko I missed your comment. This seems to be a general problem of visualization depends on. PGFPLOTS defines the error message \def\thisrow@1{thisrow_unavailable_...} in pgfplotscoordprocessing.code.tex and provides an alternative \getthisrow. But its syntax is different form the former , so in visualization depends on it fails. – Symbol 1 Jan 14 '16 at 4:15
  • Please, move explanation from your comment into your answer. It seems to be essential. – Zarko Jan 14 '16 at 4:19
  • Some recent progress could be found here: tex.stackexchange.com/a/356790/51022 – Symbol 1 Mar 5 '17 at 14:50
  • Thank you for info.I looked it. Nice answer, but to understand it, I need more time :) (+1) – Zarko Mar 5 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.