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'm drawing a multi-segment line with TikZ as below:

\begin{figure*}
\center
\begin{tikzpicture}
    \draw[->] (0.25,0) --(0.75,1.2) -- (1.25,1.5) -- (1.75,0.7) -- (2.25,1.1) -- (2.75,0.5) -- (3.25,1.5) -- (4.25,1.8);
\end{tikzpicture}
\end{figure*}

I'd like a few of the segments of the line to be thick, and the rest to be thin. Or, put another way, I'd like the line to be thick from (0.25,0) up until (1.75,0.7).

If I just do \draw[thick] ... the whole line becomes thick, which is not what I want.

Any thoughts?

Thanks!

share|improve this question
    
This isn't possible without splitting the path into segments, or doing something a little fancy. See tex.stackexchange.com/q/43309/86 for one way to do this. Is that close to what you want? –  Andrew Stacey Apr 11 '12 at 16:27
    
That looks pretty good, but I couldn't get it working, and it's unclear if you can mix to[] blocks with -- connections. –  Richard Apr 11 '12 at 16:46
    
@AndrewStacey, I've commented on the answer you linked to above - the code there doesn't seem to be working. –  Richard Apr 11 '12 at 16:49
1  
There was a spurious blank line. I've removed it. –  Andrew Stacey Apr 11 '12 at 17:51
add comment

2 Answers

up vote 4 down vote accepted

The solution is somewhere on the site but about dashed line and solid line. I can't find this answer but I will delete my answer if someone gives the good link

\documentclass{minimal}
\usepackage{tikz} 

\tikzset{%
xultra thick/.style={to path={%
\pgfextra{%
 \draw[line cap=round, line join=round,ultra thick]
      (\tikztostart) -- (\tikztotarget);} (\tikztotarget) \tikztonodes}},
xthin/.style={to path={%
\pgfextra{%
 \draw[line cap=round, line join=round,thin] 
       (\tikztostart) -- (\tikztotarget);} (\tikztotarget)  \tikztonodes}}} 
\begin{document}
\begin{tikzpicture}
  \draw (0.25,0) -- (0.75,1.2) -- (1.25,1.5) 
  to[xultra thick]  (1.75,0.7) -- (2.25,1.1) -- (2.75,0.5)
                 -- (3.25,1.5) to[xthin] (4.25,1.8);
\end{tikzpicture}
\end{document} 

enter image description here

share|improve this answer
    
I think this is the original question and this is your nice elaboration. –  percusse Apr 11 '12 at 17:15
    
No there is another answer with xdashed and xsolid styles. –  Alain Matthes Apr 11 '12 at 17:31
add comment

In a very basic way you can break the segment into two subsegments:

\begin{tikzpicture}
\draw[thick] (0.25,0) --(0.75,1.2) -- (1.25,1.5) -- (1.75,0.7); 
\draw[->] (1.75,0.7) -- (2.25,1.1) -- (2.75,0.5) -- (3.25,1.5) -- (4.25,1.8);
\end{tikzpicture}

Another solution that allows you to decide the thickness of the line is:

 \begin{tikzpicture}
 \draw[line width=1pt] (0.25,0) --(0.75,1.2) -- (1.25,1.5) -- (1.75,0.7); 
 \draw[->,line width=0.5pt](1.75,0.7) -- (2.25,1.1) -- (2.75,0.5) -- (3.25,1.5) -- (4.25,1.8);
 \end{tikzpicture}
share|improve this answer
add comment

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.