[Tex/LaTex] Graphing a line from two coordinates

graphsline

Very new LaTeX user here!

There are a ton of impressive graphs on this site. I, however, am trying to make a nice looking line on a simple graph by plotting two (x,y) coordinates: (8, 2) and (-2, -3).

Can somebody please help me with this? Here's what I had in mind: http://www.algebrahelp.com/worksheets/cache/graph_10027_a.png

I've found a lot of information on parabolic graphs and much more advanced stuff, but nothing on really simple graphs.

Here's what I made:

\begin{tikzpicture}
    \draw [thin, gray, ->] (0,-5) -- (0,5) 
    node [above, black] {$y$};  
    \draw [thin, gray, ->] (-10,0) -- (10,0)   
    node [right, black] {$x$};              
    \draw [draw=red,ultra thick] (8,2) -- (-2,-3);  
\end{tikzpicture}

I spent a long time trying to figure this out and mad a pretty stupid looking graph (which is huge):

My stupid graph

Best Answer

I would recommend using pgfplots instead of directly using tikz:

enter image description here

Notes

  • The reason for suggesting the use of pgfplots (instead of tikz) is that tikz is designed for drawing and pgfplots (which uses tikz) is designed specifically for graphing. So, if what you are doing is graphing, you should use the tool that was designed for that. Sure, you can use tikz (especially for the image given in the question), but then when you want to add tick marks, a grid, perhaps a legend in the case of multiple equations on one graph, you end up doing a lot of the work that pgfplots has already done for you.

Code:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture} 
\begin{axis}
    \addplot [mark=none,  red,   ultra thick] coordinates { (8,2) (-2,-3)};
\end{axis} 
\end{tikzpicture}
\end{document}
Related Question