Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to draw a picture using TikZ in LaTeX. In this example, I have drawn two curved lines and a vertical line. I would like to make the lower curved line only visible to the right of the vertical line. In other words, I would like to clip the lower curved line. However, I do not want to clip the entire picture. I would still like to view the entire top curve. Is this possible in TikZ?

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=5]
\draw (.1,1.6) .. controls (.6,1.6) and (1.5,1) .. (2,1);
\draw (.1,1) .. controls (.6,1) and (1.5,.4) .. (2,.4);
\draw[dashed] (1,0) -- (1,2);
\end{tikzpicture}

\end{document}
share|improve this question
1  
@Tom I changed the question slightly to more clearly indicate that I didn't want to clip the entire picture, but just the one curve. Sorry for the confusion. –  profj Mar 22 '12 at 21:30

1 Answer 1

up vote 13 down vote accepted

Yes, you can use the \clipcommand inside a scope:

\documentclass{article}

\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}[scale=5]

\begin{scope}
    \clip(1,0) rectangle (2,2);
    \draw (.1,1.6) .. controls (.6,1.6) and (1.5,1) .. (2,1);
\end{scope}

\draw[dashed] (1,0) -- (1,2);

\end{tikzpicture}

\end{document}

enter image description here


Only the things in the scope are clipped:

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=5]
\draw (.1,1.6) .. controls (.6,1.6) and (1.5,1) .. (2,1);

\begin{scope}
    \clip (1,0) rectangle (2,2);
    \draw (.1,1) .. controls (.6,1) and (1.5,.4) .. (2,.4);
\end{scope} 

\draw[dashed] (1,0) -- (1,2);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
1  
Oops let me delete mine :) –  percusse Mar 22 '12 at 21:28
2  
@percusse: same idea, and also around immedeately? I know that feeling ;) –  Tom Bombadil Mar 22 '12 at 21:33
    
@Tom Thanks! This is exactly what I was looking for. –  profj Mar 22 '12 at 21:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.