[Tex/LaTex] Cartesian coordinate / Cartesian plane

tikz-pgftkz-collection

I designed that Cartesian plane.

\documentclass[border=3]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
  \begin{tikzpicture}
    \tkzInit[xmin=-6,ymin=-6,xmax=6,ymax=6]
    \tkzAxeXY
    \tkzGrid
    \coordinate (a) at (2.0,0.0);
    \coordinate (b) at (4.0,3.0);
    \coordinate (c) at (-3.0,-5.0);
    \coordinate (d) at (-4.0,2.0);   
    \draw [color=black,fill=gray,fill opacity=0.5] (a) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (b) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (c) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (d) circle (0.1cm);
  \end{tikzpicture}
\end{document}

I should make some changes.

How can I add a letter near each point?

How can I increase the thickness of the x and y axis?

I would like to increase the size of the numbers.

I would like to put the + sign for all the positive numbers.

Thanks so much.

Best Answer

  • add a label to the \coordinates, see example below.
  • \tkzAxeXY[very thick], for example.
  • \tkzAxeXY[label options={font=\Large}] for example. (Of course, add that option in addition to very thick, see example below.)
  • \tkzAxeXY uses \numprint from the numprint package to print numbers, so you can add the \npaddplus macro from that package right after \begin{tikzpicture}.
  • \tkzAxeXY[orig=false] to remove zeros, and then add the one zero without plus sign manually, with \node [below right=3pt,fill=white,font=\Large] {$0$};.

output of code

\documentclass[border=3]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
    % \tkzAxeXY uses numprint for number printing
    % this macro turns on explicit plus signs
    \npaddplus

    \tkzInit[xmin=-6,ymin=-6,xmax=6,ymax=6]
    \tkzGrid % moved before \tkzAxeXY
    \tkzAxeXY[
       very thick, % increase width of axes lines
       label options={font=\Large,}, % increase font size 
       orig=false % don't print zeros
    ]
    % add zero label manually
    \node [below right=3pt,fill=white,font=\Large] {$0$};

    % use label=<position>:<text> to add labels next to coordinates
    \coordinate [label=above right:$A$] (a) at (2.0,0.0);
    \coordinate [label=above left:$B$] (b) at (4.0,3.0);
    \coordinate [label=below right:$C$] (c) at (-3.0,-5.0);
    \coordinate [label=below left:$D$] (d) at (-4.0,2.0);   
    \draw [color=black,fill=gray,fill opacity=0.5] (a) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (b) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (c) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (d) circle (0.1cm);
\end{tikzpicture}
\end{document}

I can't find a way of moving the axis labels, so below is a bit of a hack. Instead of \tkzAxeXY, I used \tkzAxeX and \tkzAxeY separately, as it seems styles can't be set separately. To change both position and font size, I added formatting macros in the label setting. So label=\raisebox{4mm}{\Large$y$} in \tkzAxeY to move the y-label up a bit and increase font size, and similarly label=\hspace{4mm}\Large$x$ for the x-axis, using \hspace to move it right.

output of following code

\documentclass[border=5mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
    % \tkzAxeXY uses numprint for number printing
    % this macro turns on explicit plus signs
    \npaddplus

    \tkzInit[xmin=-6,ymin=-6,xmax=6,ymax=6]
    \tkzGrid % moved before \tkzAxeXY
    \tkzAxeX[
       label=\hspace{4mm}\Large$x$,
       very thick, % increase width of axes lines
       label options={font=\Large}, % increase font size 
       orig=false % don't print zeros
    ]
    \tkzAxeY[
       label=\raisebox{4mm}{\Large$y$},
       very thick, % increase width of axes lines
       label options={font=\Large,}, % increase font size 
       orig=false % don't print zeros
    ]
    % add zero label manually
    \node [below right=3pt,fill=white,font=\Large] {$0$};

    % use label=<position>:<text> to add labels next to coordinates
    \coordinate [label=above right:$A$] (a) at (2.0,0.0);
    \coordinate [label=above left:$B$] (b) at (4.0,3.0);
    \coordinate [label=below right:$C$] (c) at (-3.0,-5.0);
    \coordinate [label=below left:$D$] (d) at (-4.0,2.0);   
    \draw [color=black,fill=gray,fill opacity=0.5] (a) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (b) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (c) circle (0.1cm);
    \draw [color=black,fill=gray,fill opacity=0.5] (d) circle (0.1cm);
\end{tikzpicture}
\end{document}