# How to create simple graph in latex

How to create simple graph in latex. x,y axis with straight line drawn at (0,0) at 45 degress through the x,y axis.

The graphs here are excellent but just too complicated for newcommers.

-
Hi tmk, Welcome to TeX.SE!. In addition to the answers below, have a look at tex.stackexchange.com/a/60428/6621 and the other questions tagged with pgfplots/pgfplots – cmhughes Aug 16 '12 at 21:08
@tmk I have merged the two accounts you seem to have, and moved your link into the question. However, the picture does not seem to be much like the plot you describe. – Joseph Wright Aug 16 '12 at 21:54
@JosephWright Thanks for the intervention. Am not an admin or super user to do those stuff.:-) – azetina Aug 16 '12 at 21:57
You should accept an answer! – gsamaras Apr 16 '15 at 19:32

You can use TikZ (the manual is really great and it has numerous examples; there's also a Minimal introduction to TikZ):

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=3]
\draw[->] (-1,0) -- (1,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,1) node[above] {$y$};
\draw[blue] +(225:1.4) -- +(45:1.4);
\end{tikzpicture}

\end{document}


\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[->] (0,0) -- (5,0);
\draw[->] (0,0) -- (0,5);
\draw[blue] (0,0) -- +(45:7);
\foreach \i/\text in {1.4/year,2.8/age,4.2/type,5.6/speed}
\draw[fill=white,draw=blue] (45:\i) circle (2pt) node[left,xshift=-2pt] at (45:\i) {\text};
\node[anchor=west] at (0,-10pt) {Colour};
\node[anchor=east] at (5,-10pt) {Make};
\node[anchor=east,text width=1cm,align=left] at (-10pt,10pt) {Engine};
\node[anchor=east,text width=1cm,align=left] at (-10pt,4.8) {Car};
\end{tikzpicture}

\end{document}


-
Thank you Gonzalo, well appreciated. will try to customize this sample, spent all day on this. the graph is actually a right angle one with straight line drawn from (0,0) to any number range. trying to label x,y and specifying my position e.g. top left, bottom left would not work. Also, tried getting dotted circle on the straight line through (0,0) to contain text but, that also was a nightmare. – tmk Aug 16 '12 at 21:09
sorry everyone, the boxes around the text in the graph are not needed. this was drawn using ms word. – tmk Aug 16 '12 at 21:59
@tmk I've updated my answer with a possible simple way to draw your diagram. – Gonzalo Medina Aug 16 '12 at 22:14
Thank you Gonzalo, your contribution is well appreciated. I have just been looking at the "pgfplots" you recommended, it is great and will get myself up to scratch in this. thank you. – tmk Aug 16 '12 at 22:22
@tmk You're welcome. Don't forget to accept one of the answers provided. – Gonzalo Medina Aug 16 '12 at 23:19

For plotting functions or data, pgfplots which is based on TikZ, is useful. A simple example is given below, and the manual has many more.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=center]