1

I have tikzpicture (with 3 graphs from my data files. I want to add legends to data1, data2 and data3 to my picture, is it possible?

\documentclass[english]{article}
\usepackage{tikz}
\usepackage{pgfplots}


\begin{document}


\begin{figure}
\begin{tikzpicture}[x=0.07cm,y=0.0025cm]

  \def\xmin{0}
  \def\xmax{170}
  \def\ymin{0}
  \def\ymax{3500}

  % grid
  \draw[style=help lines, ystep=500, xstep=10] (\xmin,\ymin) grid
  (\xmax,\ymax);

  % axes
  \draw[->] (\xmin,\ymin) -- (\xmax,\ymin) node[right] {$x$};
  \draw[->] (\xmin,\ymin) -- (\xmin,\ymax) node[above] {$y$};

  % xticks and yticks
  \foreach \x in {0,10,...,170}
    \node at (\x, \ymin) [below] {\x};
  \foreach \y in {0,500,...,3500}
    \node at (\xmin,\y) [left] {\y};


   \draw[color=green] plot[no marks] file {data1.dat}
   node [right] {data1};
  \draw[color=blue] plot[no marks] file {data2.dat}
   node [right] {data2};
     \draw[color=red] plot[no marks] file {data3.dat}
   node [right] {data3};


\end{tikzpicture}

\end{figure}
\end{document}
wefwefwe
  • 443

0 Answers0