0

Since this question doesn't have an answer yet, I've been trying to take matters into my own hands. My aim is a sine curve which fades from nothing on the left, to bold on the right.

Preferably I would use the fadings library for this:

\draw [domain=-2:2, path fading=west] plot (\x, {(1/15) * sin(18*\x r)});

But for some reason that doesn't work. If any one knows why not, that would be great but that's the topic of the question I linked above.

So I thought I'd do the fading myself with the following loop:

\foreach \x/\opac in {0.5/0.1, 1/0.2, 1.5/0.3, 2/0.4} {
\draw [domain=\x:\x+0.5, ultra thick, opacity=\opac] 
      plot (\x, {(1/15) * sin(18*\x r)}); }

But if you try this you'll see that the different plots don't match up perfectly at the end/beginning of the domains. There are overlaps and underlaps which mean this looping method isn't working for me to make a fake fading. Anybody know why this is? The problem seems to be essentially the angles of the beginning and end of the plotted lines aren't consistent.

Torbjørn T.
  • 206,688
thosphor
  • 1,193
  • 1
  • 12
  • 24
  • Are you still using an axis environment from pgfplots? A full MWE would be useful here. Also, I get nervous when I see \x used by nested loops. – John Kormylo Nov 11 '16 at 15:26
  • @JohnKormylo A MWE would simply add a \begin{document} and \begin{tikzpicture} and similarly at the end. What's in the question is the entirety of the drawing. What's wrong with \x? It's a traditional name for a variable in an equation, and the name of a direction/axis. In this case it represents both. – thosphor Nov 11 '16 at 16:25
  • If you are not using an axis environment, the domain applies only within the plot itself and has no relation to the screen coordinates. As for the nested loops, it should be legal here since each step of the loop is inside its own group (nothing is saved), but as an old programmer it still makes me nervous. – John Kormylo Nov 11 '16 at 16:32

0 Answers0