I would like to combine a curve defined with \draw
with a random variation along the path.
So far I have found quite some interesting discussions on tex.SE like How to draw Brownian motions in tikz/pgf, How to fix the trajectory of Brownian motions which generated by the "rand" function with tikz in beamer frames, and (thanks to Kpym, I have overseen this) Simulating hand-drawn lines, but they do not work as expected.
Using tikz-decorations looks promising, but only for relatively straight curves.
The following MWE gives this result:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}[x=5mm,y=5mm,decoration={random steps,segment length=3mm,amplitude=1mm}]
\draw[thick,green] (0, 1) -- (14.5, 1);
\draw[thick,red,decorate,rounded corners] (0,-0.5) -- (14.5,-0.5);
\draw[thick,blue,decorate,rounded corners] (0, 0.5) -- (1,0.5) -- (1.5,-4) -- (2,-3.5) -- (3.5,-2) -- (14.5, 0);
\end{tikzpicture}
\end{document}
The third (blue) \draw
command produces not the result that I try to get - even the red line has a "hickup" at about 75% of the way in x direction.
According to the tikz-manual the reason is: The end of each step is perturbed both in x- and in y-direction by two values drawn uniformly from the interval [−d,d], where d is the value of amplitude. This conflicts with the curved option where variing only the y value should give the desired output. Since the plots describe the change of a value in time they may not turn towards the negative x direction.
Is there any way to restrict the random steps
decoration to manipulate only the x value but not y? The alternative would be to overlay a curve by a random distortion at descrete intervals like brownian motions...
Hoping the results are somehow stable (which conflicts with the idea of random shifts - lol) there's no real need to control seeds...
\draw (0,0) \foreach \x in {1,...,10} { -- ++(0.1,rand*0.1) };
from tex.stackexchange.com/a/59927/121799 ? Or could you try to make your question a bit clearer? Your code hasrounded corners
, which is the reason for the "hick-ups" but you mention these not in your question.\draw (0,0) \foreach \x in {1,...,10} { -- ++(0.1,rand*0.1) }
will give me a basically straight line, right? So this would result in loosing control over the general shape. Working for the red line, but not for the blue. Therounded corners
are used to make the line smoother... Without them the interval of variation has to be reduced which makes the line too "waggy"...rounded corners
andsmooth
are two very different things You can draw a smooth curve but this is very different fromrounded corners
where you get the same radius (unless you make additional efforts). Anyway, I added an answer that should answer "Is there any way to restrict the random steps decoration to manipulate only the x value but not y?". If that's not what you want, it would be great if you could clarify your question.