TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the easiest way to draw a 3d coordinate system in tikz with axis labels and ticks like the following one:


Is there any additional package which does this (with adjustable parameters)?

share|improve this question
This diagram looks awfully crowded. Are you sure that's the output you want? You may prefer something like the example on pages 17-18 in the tikz-3dplot manual. In any case, the latter package is a good one for that kind of graphics. – Jubobs Jun 1 '13 at 13:14
Yes I want it with ticks and labels (and control over it). – student Jun 1 '13 at 13:19

I used the xyz coordinate system:



% The axes
\draw[->] (xyz cs:x=-13.5) -- (xyz cs:x=13.5) node[above] {$x$};
\draw[->] (xyz cs:y=-13.5) -- (xyz cs:y=13.5) node[right] {$z$};
\draw[->] (xyz cs:z=-13.5) -- (xyz cs:z=13.5) node[above] {$y$};
% The thin ticks
\foreach \coo in {-13,-12,...,13}
  \draw (\coo,-1.5pt) -- (\coo,1.5pt);
  \draw (-1.5pt,\coo) -- (1.5pt,\coo);
  \draw (xyz cs:y=-0.15pt,z=\coo) -- (xyz cs:y=0.15pt,z=\coo);
% The thick ticks
\foreach \coo in {-10,-5,5,10}
  \draw[thick] (\coo,-3pt) -- (\coo,3pt) node[below=6pt] {\coo};
  \draw[thick] (-3pt,\coo) -- (3pt,\coo) node[left=6pt] {\coo};
  \draw[thick] (xyz cs:y=-0.3pt,z=\coo) -- (xyz cs:y=0.3pt,z=\coo) node[below=8pt] {\coo};
% Dashed lines for the points P, Q
  (xyz cs:z=-5) -- 
  +(0,7) coordinate (u) -- 
  (xyz cs:y=7) -- 
  +(-5,0) -- 
  ++(xyz cs:x=-5,z=-5) coordinate (v) --
  +(0,-7) coordinate (w) --
\draw[dashed] (u) -- (v);
\draw[dashed] (-5,7) -- (-5,0) -- (w);
\draw[dashed] (3,0) |- (0,5);

% Dots and labels for P, Q
\node[fill,circle,inner sep=1.5pt,label={left:$Q(-5,-5,7)$}] at (v) {};
\node[fill,circle,inner sep=1.5pt,label={above:$P(3,0,5)$}] at (3,5) {};
% The origin
\node[align=center] at (3,-3) (ori) {(0,0,0)\\\text{origin}};
\draw[->,help lines,shorten >=3pt] (ori) .. controls (1,-2) and (1.2,-1.5) .. (0,0,0);


enter image description here

share|improve this answer

A suggestion with pgfplots. There is an issue with the y-ticks though, as both horizontal and vertical lines are drawn, making the ticks a plus sign. Don't know why this happens.

  axis lines=center,
  minor tick={-12,-11,...,12},

% plot dots for the two points
\addplot3 [only marks] coordinates {(-5,-5,7) (3,0,5)};

% plot dashed lines to axes
\addplot3 [no marks,densely dashed] coordinates {(0,0,5) (3,0,5) (3,0,0)};
\addplot3 [no marks,densely dashed] coordinates {(0,-5,0) (-5,-5,0) (-5,0,0) (-5,0,7) (0,0,7) (0,-5,7) (0,-5,0)};
\addplot3 [no marks,densely dashed] coordinates {(-5,0,7) (-5,-5,7) (0,-5,7)};
\addplot3 [no marks,densely dashed] coordinates {(-5,-5,0) (-5,-5,7)};

% label points
\node [above right] at (axis cs:3,0,5) {$P (3,0,5)$};
\node [above left] at (axis cs:-5,-5,7) {$Q (-5,-5,7)$};
\node [inner sep=2pt,outer sep=0pt] (O) at (axis cs:0,0,0) {};
\node [align=center] (origin) at ([xshift=1.5cm,yshift=-1.3cm]O) {$(0,0,0)$ \\Origin};
\draw [shorten <=.1cm,stealth-,gray] (O) to [out=-30,in=160] (origin.west);

enter image description here

share|improve this answer

Your Answer


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.