# Problems in creating graphs using dataplot

I have four simple databases:

db1

dy,volume
2009,120000
2010,160000
2011,400000
2012,650000
2013,1000000
2014,1500000


db2

dy,volume
2009,400000
2010,500000
2011,1600000
2012,2200000
2013,2500000
2014,4000000


db3

dy,volume
2009,100000
2010,120000
2011,150000
2012,160000
2013,400000
2014,1000000


db4

dy,volume
2009,250000
2010,400000
2011,750000
2012,900000
2013,1400000
2014,3000000


And with these four files I like to create a simple graphical representation like this. I am using dataplot package for this purpose. And here is my source file:

test.tex

\documentclass{book}
\usepackage{dataplot}
\begin{document}

\begin{figure}[htbp]
\centering
\DTLplot{db1,db2,db3,db4}{x=dy,y=volume,
width=3in,height=3in,style=lines,legend,legendlabels={Legend1,Legend2,Legend3,Legend4},
xlabel={Year},ylabel={Volume},box,
xticpoints={2009,2010,2011,2012,2013,2014}
}

\caption{A simple graph}

\end{document}


But, I am getting this error over and over saying:

Package datatool Error: Can't assign \DTLthisX : there is no key dy' in database db1'.


If there is someone who could help me out in this regard, either pointing my error or any useful information to handle this.

One more question:

As my database contains huge numbers (i.e., > 100000), how can I manage to show this on y-axis as 100k and so on. Where k denotes a kilo. Any ideas.

-

I'm not familiar with dataplot, but here is an example of what you can do with pgfplots; I've only plotted the first two sets of data, but you can easily build on the existing code to include the last two.

Regarding the "huge numbers" on the y-axis, whether you end up using dataplot or pgfplots, I strongly advise you to multiply them by 10^{-6} and specify that factor in the y-label; the numbers become much easier to read (nobody likes to count loads of zeros). However, it's really up to you.

I've used filecontents to simulate the existence of your .cvs files.

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.3}

\begin{document}

\begin{filecontents*}{db1.cvs}
dy,volume
2009,120
2010,160
2011,400
2012,650
2013,1000
2014,1500
\end{filecontents*}

\begin{filecontents*}{db2.cvs}
dy,volume
2009,400
2010,500
2011,1600
2012,2200
2013,2500
2014,4000
\end{filecontents*}

\begin{tikzpicture}
\begin{axis}[%
width=\textwidth,
ylabel shift=1ex,
enlargelimits=0.13,
tick align=outside,
legend style={cells={anchor=west},legend pos=north east},
xtick={2009,2010,...,2014},
xticklabels={2009,2010,2011,2012,2013,2014},
ytick={500,1000,...,4000},
yticklabels={500k,1000k,1500k,2000k,2500k,3000k,3500k,4000k},
xlabel=\textbf{year},
ylabel=\textbf{volume}
]
\addplot[mark=none,blue] table [x=dy, y=volume, col sep=comma] {db1.cvs};

@Cylian You can load external files as \addplot file {db1.dat}; @Jubobs +1 for nice answer, but it would be nice if the years were written as 2009 not 2,009 –  Ipsen Mar 28 '13 at 8:34