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.

Is it possible to draw thick curve between (2,2) (4,3). Remaining portion must be thin.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [blue] plot [smooth] coordinates {(0,0) (2,2) (4,3) (5,5) (0,10)};
\end{tikzpicture}
\end{document}
share|improve this question

1 Answer 1

up vote 13 down vote accepted

1)

Here is a simple solution (via clip action) for your specific MWE.

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\def\mycoordinates{(0,0) (2,2) (4,3) (5,5) (0,10)}
\begin{document}
\begin{tikzpicture}
  \draw [blue,thin] plot [smooth] coordinates {\mycoordinates};
  \begin{scope}
    \clip (0,2) rectangle (5,3);
    \draw [red,very thick] plot [smooth] coordinates {\mycoordinates};
  \end{scope}
\end{tikzpicture}
\end{document}

2)

Here is more general solution (via show path construction decoration).

The style between style requires three arguments: {<coord#1>}{<coord#2>}{<special style>}. The special style is applied on segments between coord#1 and coord#2.

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}
\newcounter{pos}
\tikzset{
  initcounter/.code={\setcounter{pos}{0}},
  style between/.style n args={3}{
    postaction={
      initcounter,
      decorate,
      decoration={
        show path construction,
        curveto code={
          \addtocounter{pos}{1}
          \pgfmathtruncatemacro{\min}{#1 - 1}
          \ifthenelse{\thepos < #2 \AND \thepos > \min}{
            \draw[#3]
            (\tikzinputsegmentfirst)
            ..
            controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
            ..
            (\tikzinputsegmentlast);
          }{}
        }
      }
    },
  },
}
\begin{document}
\begin{tikzpicture}
  \draw [
  style between={2}{4}{red,thick},
  style between={5}{8}{green,very thick},
  blue,thin] plot [smooth]
  coordinates {(0,0) (4,0) (2,4) (1,1) (3,1) (1,3) (0,1) (1,0) (4,4)};
\end{tikzpicture}
\end{document}
share|improve this answer

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.