I have the following code that produces a line chart:
\begin{figure}[p]
\centering
\begin{tikzpicture}
\begin{axis}[
use units,
cycle list name=exotic, %This defines the color. It produces nicer colors
width=15cm, height=8cm, % size of the image
grid = major,
grid style={dashed, gray!30},
%xmode=log,log basis x=10,
%ymode=log,log basis y=10,
xmin=0, % start the diagram at this x-coordinate
ymin=0, % start the diagram at this y-coordinate
%/pgfplots/xtick={0,5,...,60}, % make steps of length 5
%extra x ticks={23},
%extra y ticks={0.507297},
axis background/.style={fill=white},
ylabel=Time,
xlabel=Number of Datapoints (n),
y unit=s,y unit prefix=m,
tick align=outside]
% import the correct data from a CSV file
\addplot table [col sep=comma,trim cells=true,y=Best Case (Ascending)] {datasets/time_mergesort.txt};
\addplot table [col sep=comma,trim cells=true,y=Average Case (Random)] {datasets/time_mergesort.txt};
\addplot table [col sep=comma,trim cells=true,y=Worst Case (Descending)] {datasets/time_mergesort.txt};
\legend{Ascending,Random,Descending}
\end{axis}
\end{tikzpicture}
\caption{Mergesort Run Time for Sorting Random Data}
\label{fig:merge_sort_from_csv}
\end{figure}
And at the moment the legend appears on the chart on the upper right corner. I need to move that below the chart, or even to leave that on the chart but to move that on the upper left corner.
I have tried the solution mentioned at this question, but it did not work for me.
How can I move the axis in a different position?
legend pos=north west
. See the manual (Section 4.9.5) for outer legend positions. It is much easier for others to help you if you provide minimal but complete examples. In this sample you have many lines of unrelated options that have nothing to do with the question. But you also leave out\documentclass{<...>}
and package loading, requiring us to type extra things to produce a document. Please see our info on minimal working examples (MWEs). – Paul Gessler Jul 5 '14 at 21:22