Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example155.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 155 Scatter Plot With Mismatched X and Y Columns
3 % Label: "ex:growthscatter6col2db2x3y"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 \usepackage{scontents}% to write test file with TABs preserved
9 \begin{scontents}[write-out={growth.tsv},overwrite]
10 Experiment 1 Experiment 2
11 Time Log Count Time Log Count
12 0 2.9 0 3.31
13 15 3.14 10 3.45
14 30 3.26 25 3.61
15 45 4.01 40 3.76
16 60 4.2 55 3.89
17 \end{scontents}
18
19 \begin{scontents}[write-out={growth2.tsv},overwrite]
20 Experiment 1 Experiment 2 Experiment 3
21 Time Log Count Time Log Count Time Log Count
22 0 3.21 0 3.39 0 3.28
23 15 3.43 10 3.51 10 3.45
24 30 3.68 25 3.65 20 3.57
25 45 4.4 40 3.84 30 3.64
26 60 4.8 55 3.92 40 3.95
27 \end{scontents}
28
29 \usepackage{dataplot}
30 \DTLsetup{store-datum}
31 \DTLread[
32 name=growthdata, format=tsv,csv-skip-lines=1,
33 keys={Exp1Time,Exp1Count,Exp2Time,Exp2Count},
34 csv-content=no-parse,
35 data-types=decimal
36 ]{growth}% growth.tsv
37
38 \DTLread[
39 name=growthdata2, format=tsv,csv-skip-lines=1,
40 keys={Exp1Time,Exp1Count,Exp2Time,Exp2Count,Exp3Time,Exp3Count},
41 csv-content=no-parse,
42 data-types=decimal
43 ]{growth2}% growth2.tsv
44
45 \begin{document}
46 % useful for debugging, this will show the column keys instead of the headers in the legend:
47 \RenewDocumentCommand \DTLplotlegendx { O{0} m O{0} m }{#4}
48 \RenewDocumentCommand \DTLplotlegendy { O{0} m O{0} m }{#4}
49
50
51 % now draw the plot:
52 \DTLplot{growthdata,growthdata2}{
53 x={Exp1Time,Exp2Time},
54 y={Exp1Count,Exp2Count,Exp3Count},
55 x-label={Time ($t$)},y-label={Log Count},
56 legend,
57 width=2.5in,height=2.5in
58 }
59 \end{document}