1

In realtion to this pretty old question (back 3 years from now) Is there a way to clear paths previously defined with name path global in TikZ? I would like to know, whether there is actually a nice feature in pgfplots v1.11 (the latest, today) that allows me to delete globally defined names.

My usecase: I want to use several addplot commands within the same tikzpicture, since my matlab2tikz gives me fine results in this. Afterwards I want to finetune these plots with several drawn arcs around given coordinates (script useses addplot table[] for this). I saw the [solution by sdaau for automatic naming of the nodes from the tables. This seems to work, but I have to somehow get into the scope of the addplots. Don't know how. Otherwise I get an error "shape MYNODE1 unknown"

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks, calc, intersections}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}


\begin{axis}[%
width=10cm,
height=10cm,
axis x line = middle,
axis y line = middle,
scale only axis,
xlabel={x [mm]},
ylabel={y [mm]},
title={$\text{n}_{\text{iterations}}\text{= 2}$}
]


\addplot+[
only marks,
mark=text, 
text mark={\coordindex}, % empty for now; try also \coordindex
text mark as node=true,
text mark style={%
name=p\coordindex,
color=orange,
shape=circle,
draw,
inner sep=0pt,
minimum size=0pt,
align=center,
text width=5pt,
text depth=0pt
}
]
table{%
    0         0     
  -79.9393  236.8749 
  143.0014  350.0007
  200.0014  350.0000
  200.0008  300.0000
};
\pgfplotsextra{ 
    \path [name path=P--C-ext] (p0) -- ($(p1)!-50!(p0)$);
    \draw (p0) -- (p1);
    \path [name path=Rim] (p1.center) circle(50);
    \path [draw, name intersections={of=P--C-ext and Rim}];

    \pgfmathanglebetweenpoints{%
            \pgfpointanchor{p1}{center}
    }{%
            \pgfpointanchor{intersection-1}{center}
    }
    \let\myendresult\pgfmathresult

    \fill [fill=blue!50,draw=blue,thin,opacity=0.5] (p1) -- (intersection-1) arc [start angle=\myendresult,delta angle=-40,radius=50] -- cycle;
    \fill [fill=blue!50,draw=blue,thin,opacity=0.5] (p1) -- (intersection-1) arc [start angle=\myendresult,delta angle=25,radius=50] -- cycle;
};

\end{axis}

\end{tikzpicture}

\end{document}

This code doesn't compile though... So second try is to use "path name global" but then I'd have several redefined nodes.

To sum up: I want automaticly named nodes from the coordinate table in addplot command. I want to use them in the same tikzpicture for attaching some shapes and arcs to them.

  • 1
    Welcome to TeX.SE. It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem - you can use the code in the linked question as starting point. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Aug 16 '14 at 18:13
  • Well, I thought of this maybe more of a conceptual question than of a discrete code solution. Sure I will setup something then. – goeck Aug 16 '14 at 18:36

Your Answer

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

Browse other questions tagged or ask your own question.