TikZ-PGF – How to Draw a Simple Cartesian Plane with Straight Lines

pgfplotstikz-pgf

enter image description here

How to generate the above plot with pgfplots?

I have an example code here:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,axis equal,grid=both]
\addplot coordinates{(-3,1) (6,-2)};
\end{axis}
\end{tikzpicture}
\end{document}

which will generate a figure as shown below:

enter image description here

I don't want grid lines to be drawn full.

Only small xticks and yticks are needed.

Don't want dots to be placed at the ends of line.

Best Answer

It can be easily done with pstricks:

    \documentclass[svgnames, pstricks, border=10pt]{standalone}
    \usepackage{pst-plot, pst-node}

    \begin{document}

    \begin{pspicture*}(-0.5,-1.5)(6,6.5)
    \psset{showorigin=false, arrowinset=0.12, linejoin=1, labelsep=1pt}
    \everypsbox{\scriptsize}
    \psaxes[labelFontSize=\scriptstyle, tickstyle=full, ticksize=2pt -2pt, Dx=1, labels=none, linecolor=LightSteelBlue]{->}(0,0)(-0.5,-1.5)(5.5, 6)[$x$,0][$y$,90]
    \pnodes(-0.5,-1.5){A} (5,4){B}(-0.5,3.5){C}(4,-1){D}
    \ncline[linecolor=Tomato]{A}{B}\naput[nrot=:U, npos=0.8]{$ x-y=1 $}
    \ncline[linecolor=LawnGreen]{C}{D}\naput[nrot=:U, npos=0.3]{$ x+y=3 $}
    \dotnode(2,1){I}\uput{4pt}[r](I){$P(2,1)$}
    \end{pspicture*}

    \end{document} 

enter image description here