Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to draw points coordinates in a graph. In my case, the problem is that the values of the x-axis and y-axis of each point can be very large. That is why I need to edit the code below in order to be able to draw the 2D points even for large coordinates values.

For example the code below works well but only for small coordinates values, I need to use it for large coordinates values without increasing the graph. Let us consider a point A(300,200).

Any help will be very appreciated!

The code is:

\documentclass{report}
\usepackage{tikz}
%\usetikzlibrary{automata,topaths}% note neded for this.
 \begin{document}
 \begin{tikzpicture}[x=1cm,y=0.4cm]

 \draw[latex-latex, thin, draw=gray] (-4,0)--(4,0) node [right] {$x$}; % l'axe des abscisses
 \draw[latex-latex, thin, draw=gray] (0,-5)--(0,5) node [above] {$y$}; % l'axe des ordonnées

\foreach \Point in {(-2,1.5), (-1,1), (-2,3), (-1,2.5), (1,3)}{
    \node at \Point {\textbullet};
}

\foreach \Point in {(2,-1.5), (1,-1), (2,-3), (1,-2.5), (1,-3)}{
    \node at \Point {$\circ$};
}

% to ensure that the points are being properly centered:
\draw [dotted, gray] (-4,-6) grid (5,5);

\end{tikzpicture}
\end{document}
share|improve this question
2  
Do you know pgfplots? An example: tex.stackexchange.com/a/61322/1952 –  Ignasi Apr 1 at 10:45
    
@lgnasi, thank you, this help well! please put your comment in an answer in order to vote up and accept your answer :) Because you resolved my problem –  Christina Apr 1 at 10:51
    
Harish already did it for me. –  Ignasi Apr 2 at 14:18

3 Answers 3

up vote 5 down vote accepted

With pgfplots and diffrent styles for different sets of numbers

\documentclass{report}

\usepackage{pgfplots}
\pgfplotsset{width=5.5in,compat=1.10}

 \begin{document}
  \begin{tikzpicture}
  \begin{axis}[axis lines=middle,
                xlabel = $x$,
                x label style={at={(1.04,0.5)}},
                ylabel = $y$,
                y label style={at={(0.5,1.05)}},
                xmin=-600,
                xmax=600,
                ymin=-5000,
                ymax=5000,
                xtick={-600,-500,-400,-300,-200,-100,100,200,300,400,500,600},
                ytick={-5000,-4000,-3000,-2000,-1000,1000,2000,3000,4000,5000},
                enlargelimits]
\addplot[
scatter,
only marks,
point meta=explicit symbolic,
scatter/classes={
a={mark=square*,blue},%
b={mark=triangle*,red},%
c={mark=o,draw=black}},
]
      table[meta=label] {
      x y label
      100 2000 a
      200 3000 c
      -400 2500 a
      500 4200 a
      200 -1000 b
      250 -1500 c
      400 -3000 b
      };
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Another solution for fun with tkz-euclide package:

\documentclass{report}

\usepackage{tkz-euclide}

 \begin{document}
  \begin{tikzpicture}
  \tkzInit[xmin=-600,xmax=600, xstep=100,
  ymin=-5000, ymax=5000,ystep=1000]
  \tkzAxeXY
  \tkzDefSetOfPoints[prefix=P]{%
        100/2000,
        200/3000,
        -400/2500,
        500/4200,
        200/-1000,
        250/-1500,
        400/-3000}
  \tkzDrawPoints[fill=black](P1,P2,P3,P4)
\tkzDrawPoints[fill=orange](P5,P6,P7)
  \end{tikzpicture}
\end{document}

Output:

enter image description here

share|improve this answer

A PSTricks solution. Run it with xelatex

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}

 \begin{document}
  \begin{pspicture}(-6.2,-5.1)(7,6)
  \psaxes[dx=2,Dx=200,dy=2,Dy=2000]{->}(0,0)(-6,-5)(6.5,5.5)[$x$,0][$y$,90]
  \pslistplot[xunit=0.01,yunit=0.001,plotstyle=dots,dotstyle=square*,linecolor=red]{
     100 2000 200 3000  -400 2500 500 4200  200 -1000 250 -1500  400 -3000}
  \end{pspicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.