1

I want to draw a diagram as the image below, but it is difficult for me to start.

PCR example

The height of vertical line represent the temperature, and the slop of slash is fix. Number above the vertical line is the temperature, and number below it is the time.

It is possible to wrap the drawing into a single function like this?

\drawPCR{[95.0,11:00]}{[94.0,1:00],[59.0,1:00],[72.0,1:00]}{[60.0,45:00],[4.0,∞]}
4

Here is a starting point. The command takes one comma-separated list of temperatures, times and an additional parameter. If the additional parameter is 1, a dashed line is drawn before it. The syntax you are suggesting should be possible with xparse but I don't know that well enough to be able to implement it.

\documentclass[border=3.14mm,tikz]{standalone}
\begin{document}
\newcommand\drawPCR[1]{%
\foreach \X/\Y/\W [count=\Z] in {#1}
 {\ifnum\Z=1
 \draw 
(0,0) -- ++({0.5*\X*1pt},{\X*1pt}) -- ++ (1cm,0) coordinate (last) node[midway,above]{\X}
 node[midway,below]{\Y};
 \xdef\Xlast{\X}
\else
 \pgfmathsetmacro{\DeltaX}{\X-\Xlast}
 \ifnum\W=1
  \draw[dotted] ([xshift={0.25*abs(\DeltaX)*1pt}]last|- 0,0) --++(0,125pt);
 \fi
 \draw (last) -- ++({0.5*abs(\DeltaX)*1pt},{\DeltaX*1pt})  -- ++ (1cm,0) coordinate (last)
 node[midway,above]{\X} node[midway,below]{\Y};
 \xdef\Xlast{\X}
\fi
 }
}
\begin{tikzpicture}[font=\sffamily\small]
\begin{scope}[thick]
\drawPCR{95.0/11:00/0,94.0/1:00/1,59.0/1:00/0,72.0/1:00/0,60.0/45:00/1,4.0/$\infty$/0}
\end{scope} 
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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