I have a list of points in a table out of which I would like to plot several closed loop paths. For each \addplot I would like to give an index list for this particular path.
The trouble is that these points aren't necessarily given as consecutive index numbers. So, I tried to combine the ideas from here and here. For each \coordindex it should be checked if it is a member of the desired list, if not it is discarded. This is what I tried
\documentclass[11pt,a4paper]{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{calc,patterns}
\newif\ifmember
\makeatletter
\newcommand{\MemberQ}[2]{\global\memberfalse%
\edef\temp{#2}%
\@for\next:=#1\do{\ifx\next\temp\relax\global\membertrue\fi}}
\makeatother
\pgfplotsset{compat=1.14, select coords/.style 1 args={
x filter/.code={
\MemberQ{#1}{\coordindex}
\ifmember \else \def\pgfmathresult{}\fi
}
}
}
\begin{document}
\pgfplotstableread[]{
x y lab
10 10 A
20 10 B
20 20 C
10 20 D
}\mytable
\begin{tikzpicture}
\begin{axis}[]
\addplot [pattern color=blue,pattern=horizontal lines,select coords ={0,2,3}] table {\mytable}--cycle;
\end{axis}
\end{tikzpicture}
\end{document}
The result is an error "Illegal parameter number in definition...". Can anyone help?
Many thanks.