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?


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.

\foreach \X/\Y/\W [count=\Z] in {#1}
(0,0) -- ++({0.5*\X*1pt},{\X*1pt}) -- ++ (1cm,0) coordinate (last) node[midway,above]{\X}
  \draw[dotted] ([xshift={0.25*abs(\DeltaX)*1pt}]last|- 0,0) --++(0,125pt);
 \draw (last) -- ++({0.5*abs(\DeltaX)*1pt},{\DeltaX*1pt})  -- ++ (1cm,0) coordinate (last)
 node[midway,above]{\X} node[midway,below]{\Y};

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.