Debian Codegraph @

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

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 166 Scatter Plot with Custom Colours and Styles (Two Databases, Multiple Sets of Data)
3 % Label: "ex:growthscatter6col2dbstyles"
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 \usepackage{siunitx}
31 \DTLsetup{store-datum}
32 \DTLread[
33 name=growthdata, format=tsv,csv-skip-lines=1,
34 keys={Exp1Time,Exp1Count,Exp2Time,Exp2Count},
35 csv-content=no-parse,
36 data-types=decimal
37 ]{growth}% growth.tsv
38
39 \DTLread[
40 name=growthdata2, format=tsv,csv-skip-lines=1,
41 keys={Exp1Time,Exp1Count,Exp2Time,Exp2Count,Exp3Time,Exp3Count},
42 csv-content=no-parse,
43 data-types=decimal
44 ]{growth2}% growth2.tsv
45
46
47 \DTLplotlegendsetname{growthdata}{\qty{6}{\degreeCelsius}}
48 \DTLplotlegendsetname{growthdata2}{\qty{8}{\degreeCelsius}}
49 \DTLplotlegendsetxlabel{Exp1Time}{$t_1$}
50 \DTLplotlegendsetxlabel{Exp2Time}{$t_2$}
51 \DTLplotlegendsetxlabel{Exp3Time}{$t_3$}
52 \DTLplotlegendsetylabel{Exp1Count}{$N_1$}
53 \DTLplotlegendsetylabel{Exp2Count}{$N_2$}
54 \DTLplotlegendsetylabel{Exp3Count}{$N_3$} \RenewDocumentCommand \DTLplotlegendxy { O{0} m O{0} m O{0} m }
55 {%
56 (\DTLplotlegendx[#1]{#2}[#3]{#4},
57 \DTLplotlegendy[#1]{#2}[#5]{#6})%
58 }
59 \begin{document}
60 \DTLplot{growthdata,growthdata2}{
61 style=both,% lines and markers
62 line-colors={brown,blue,lime,black,orange},
63 mark-colors={magenta,teal,green,violet,cyan},
64 lines={
65 \pgfsetdash{}{0pt},% solid line
66 \pgfsetdash{{1pt}{3pt}}{0pt},
67 \pgfsetdash{{5pt}{5pt}{1pt}{5pt}}{0pt},
68 \pgfsetdash{{4pt}{2pt}}{0pt},
69 \pgfsetdash{{1pt}{1pt}{2pt}{2pt}{2pt}{1pt}}{0pt}
70 },
71 marks={
72 \pgfuseplotmark{o},
73 \pgfuseplotmark{square},
74 \pgfuseplotmark{diamond},
75 \pgfuseplotmark{asterisk},
76 \pgfuseplotmark{star}
77 },
78 x={Exp1Time,Exp2Time,Exp3Time},
79 y={Exp1Count,Exp2Count,Exp3Count},
80 x-label={Time ($t$)},y-label={Log Count},
81 legend, legend-offset={-10pt,0pt},
82 width=2.5in,height=2.5in
83 }
84 \end{document}