This is something very basic that I've often been slightly annoyed with when using Tikz, mostly since I think I've seen that it is possible somewhere before and I'm annoyed with myself for not remembering. However, after trying several keyword combinations, Google has not obliged me. It is of course perfectly possible that I still just haven't found the right keywords to try (English is not my native language) or that it is so basic everyone knows. The latter seems somewhat unlikely though, considering the stupendous amount of basic questions being asked all over the internet about anything whatsoever.
Anyway, here's an MWE for what I'm trying to do:
\documentclass[border=1cm]{standalone}
\usepackage{pgfplots,tikz}
\begin{document}
\begin{tikzpicture}
\draw[rounded corners=1cm] (-2,5) -- (-2,0) -- (-0.4,0);
\draw[rounded corners=1cm] (0.4,0) -- (2,0) -- (2,5);
\end{tikzpicture}
\end{document}
Output:
So my question is whether it is possible to do this with a single \draw
command, i.e. is there an alternative to --
that will just "move my pencil" to the next coordinate given without drawing the line? Or in yet other words: can I straightforwardly suspend the draw command for a given portion of a path?
You've probably noticed my MWE isn't completely minimal since the rounded corners and even the vertical lines are actually superfluous to my question, but otherwise the question seems even more trivial than it already does. It's not that much extra work to do it the way I have (in this case) but I'm a sucker for efficiency and logical clarity. Besides, larger pictures might require (a lot) more extra work.
(0,0) -- (1,1) (-1,2) -- (3,5)
? Is that what you mean?\draw[rounded corners=1cm] (-2,5) -- (-2,0) -- (-0.4,0) (0.4,0) -- (2,0) -- (2,5);
?\documentclass[border=1cm,tikz]{standalone}\begin{document}\tikz\draw[rounded corners=1cm] (-2,5) |- (-0.4,0) (0.4,0) -| (2,5);\end{document}