# help with pgfplot a .csv data file

So i'm really new to pgfplot, a couple of hours now and I'm trying to build a graph such as this:

https://www.dropbox.com/s/o3yq97oc9rwmthh/mcgreedy.csv?dl=0 Here is the .csv file!

x-axis is the experiment trial y-axis has 2 different algorithms and the score they yield at each trial

I'm getting some errors that have to do with my attempt of plotting a simple line {x+1} which for now, i'm only trying to do to get a visualisation of what I'm doing

Thanks everyone!

\begin{tikzpicture}
\begin{axis}[
width=10cm,
grid = major,
grid style = {dashed, gray!30},
xmin = 0,
ymin = 0,
xmax = 105,
ymax = 280,
/pgfplots/xtick = {0,5,...,100},
axis background/.style = {fill=white},
ylabel = {Trial Number},
xlabel = {Score},
tick align = outside,
]
\end{axis}
\end{tikzpicture}

• Hi, and welcome! What does mcgreedy.csv look like? Which errors do you get? – Torbjørn T. May 16 '16 at 16:43

You were just missing a semicolon at the end of the \addplot line. And by default just one plot is added from a file, so you need two, one for each series.

• If you want the legend entries displayed in a row, as in your screenshot, add legend columns=-1.
• I think there should be some more space between the xticklabels. You can for example reduce the font size a bit (ticklabel style={font=\small}), increase the width of the axis (if there's room), or have fewer ticks. A tick every 10 points may be enough here.
• Note that you don't need /pgfplots/ before xtick.

\documentclass{article}
\usepackage{pgfplots,showframe}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
width=0.95\linewidth,
height=0.6\linewidth,
grid = major,
grid style = {dashed, gray!30},
xmin = 0,
ymin = 0,
xmax = 105,
ymax = 280,
xtick = {0,10,...,100},
ylabel = {Trial Number},
xlabel = {Score},
tick align = outside,
legend pos=south east,
legend columns=-1
]

\legend{ECTS, E.G.}
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
width=0.95\linewidth,
height=0.6\linewidth,
grid = major,
grid style = {dashed, gray!30},
xmin = 0,
ymin = 0,
xmax = 105,
ymax = 280,
xtick = {0,5,...,100},
ticklabel style={font=\small},
ylabel = {Trial Number},
xlabel = {Score},
tick align = outside,
legend pos=south east,
legend columns=-1
]

(The frame shows the text area, generated by the showframe` package.)