3

I would like to use the data of an external file as the clipping path with Tikz. Something in the line of:

\documentclass[10pt,tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{filecontents*}{spiral.dat}
6.5066069e-01  -7.0560046e-01
5.7783540e-01  -7.4892495e-01
5.0112891e-01  -7.8376476e-01
4.2139313e-01  -8.0997113e-01
3.3947853e-01  -8.2749913e-01
2.5623414e-01  -8.3640761e-01
1.7250756e-01  -8.3685920e-01
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \clip file {spiral.dat};
    \fill[red] (0,0) circle (5cm);
\end{tikzpicture}
\end{document}

Obviously, what is above does not work but is there an existing similar strategy? I could also directly define the clipping path in the Tike figure by importing the data from the external file but I want to avoid this.

  • The provided path is not closed but this is just an illustrative example. I was not aware of the tikzfadingfrompicture feature. How could it be adapted here? – pluton Nov 15 '14 at 22:29
  • Actually doesn't seem to work with draw rather than fill so you'd still need a closed path (or let TiKZ close it, of course). – cfr Nov 15 '14 at 23:12
3

You can plot the file but you need floats not sci representations. Then you can use simply \clip plot file {spiral.dat};.

Otherwise you can read the table via pgfplotstable and carry out the coordinate creation that TikZ would understand, or simply use pgfplots

Sane input table

\documentclass[10pt,tikz]{standalone}

\begin{filecontents*}{spiral.dat}
1.00000000  -0.10000000
0.98518595  -0.19563549
0.96101356  -0.28698521
0.92795372  -0.37325320
0.88655701  -0.45369864
0.83743510  -0.52767006
0.78126033  -0.59460623
0.71875144  -0.65404381
0.65066069  -0.70560046
0.57783540  -0.74892495
0.50112891  -0.78376476
0.42139313  -0.80997113
0.33947853  -0.82749913
0.25623414  -0.83640761
0.17250756  -0.83685920
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
    \clip plot[no marks] file {spiral.dat};
    \fill[red] (0,0) circle (5cm);
\end{tikzpicture}
\end{document}
| improve this answer | |

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.