Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm attempting to draw a plot, using pgfplots, where the start and end coordinates are intersection points I have computed earlier in the same tikzpicture. I start by defining the paths and intersections, but when I input the names of the intersection points as coordinates in the addplot command, the document won't compile. The error message reads:

pdflatex> ! Package PGF Math Error: Unknown function `t' (in 't-1)(-10.869411').

Obviously I'm doing something wrong. Does anyone know how I can use previously defined intersection points within the addplot command?

Here is the essence of the code I'm trying to compile:

\documentclass[11pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz,pgfplots}
    \usetikzlibrary{intersections}
\pgfplotsset{compat=newest}
\begin{document}

    \begin{tikzpicture}

         \begin{axis}[view={0}{90}, width=10cm, height=7cm, scale only axis, axis equal,
                      xmin=-17.936700408998, xmax=5.89970040899796, ymin=12.5, ymax=31.3,]

             \path[name path=topslant] (axis cs: -0.529628,27.8830164982243) -- (axis cs: -0.445369,28.2419383436497);
             \path[name path=top] (axis cs: 0,31.272) -- (axis cs: -00.15,28) -- (axis cs: -1,28.12);
             \path[name intersections={of=topslant and top, name=t}];

             \path[name path=bottomslant] (axis cs: -12.037,12.52) -- (axis cs: -10.869411,13.6420106655631);
             \path[name path=corner] (axis cs: -12,12.07) -- (axis cs: -11.133,12.921) -- (axis cs: -11.574,13.3);
             \path[name intersections={of=bottomslant and corner, name=c}];

             \addplot[color=blue, solid]
                 coordinates{
                     (t-1)(-10.869411,13.6420106655631)(-2.756473,22.6522459312844)(-0.529628,27.8830164982243)(c-1)
                 };

        \end{axis}
    \end{tikzpicture}
\end{document}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

\addplot coordinates expects absolute coordinates, it cannot deal with node references.

The reason is that \addplot coordinates talks to / defines the axis: its arguments are used to compute axis limits, perhaps even transform coordinate spaces etc. It does not know anything about axis limits of "t" and it cannot apply any kind of transformations (like logs) to "t". That's why it expects coordinates.

An alternative would be to use \draw instead of \addplot and use axis cs instead of the default coordinate systems.

share|improve this answer
    
This was just what I needed. Thanks for the explanation. For some reason I assumed that at least one plot was necessary. I swear that almost every time I encounter a problem with LaTeX, it's because I overthink everything. –  eiterorm Mar 4 at 0:57
    
Well, it is all quite complex and has huge manuals :-( . I suppose the best way is to be optimistic and see if something works... in general, you can omit \addplot if you assign all axis limits manually (as in your example). –  Christian Feuersänger Mar 4 at 7:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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