[Tex/LaTex] Can we mirror a part in tikz (“axial symmetry”, “reflection”)

tikz-pgf

After drawing a part in TikZ, is it possible to mirror that part with respect to some axis or line?

MWE

 \documentclass{standalone}

 \usepackage{tikz}

 \begin{document}

 \begin{tikzpicture}
 \draw[step=1.0,gray,thin] (0,0) grid (4,3);
 \draw [thick](1,1) -- (0,0) -- (1,2); % Original Image
 \draw [ultra thick,red] (2,0) -- (2,3); %axis
 % code for Mirror Image
 \draw [thick,blue](3,1) -- (4,0) -- (3,2); % Mirror Image
 \end{tikzpicture}

 \end{document}

enter image description here

Best Answer

You can use a scope and invert xscale and yscale as a whole. This is just another method of doing what ipsen did. The scope will be useful in reflecting only a part of the image.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (-1,1) -- (0,0) -- (1,1); % Original Image
\begin{scope}[yscale=-1,xscale=1]
  \draw[red] (-1,1) -- (0,0) -- (1,1); % Mirror Image
\end{scope}

\end{tikzpicture}

\end{document}

enter image description here

Update:

You can use xscale/yscale in combination with xshift/yshift to get the desired effect.

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[step=1.0,gray,thin] (0,0) grid (4,3);
\draw [thick](1,1) -- (0,0) -- (1,2); % Original Image
\draw [ultra thick,red] (2,0) -- (2,3); %axis
% code for Mirror Image
\begin{scope}[xscale=-1,xshift=-4cm]
\draw [thick,blue](1,1) -- (0,0) -- (1,2);  % Mirror Image
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here