I'd like to use TiKZ to generate stand-alone PDF diagrams programatically. I have an application that generates simple geometry of lines and arcs etc and I'd like to create (using e.g. Ruby) TikZ diagram text files from that simple geometry.

I have a bounding box (AABB) of each chunk of geometry and my question is what is the most idiomatic TiKZ and LaTeX/ConTeXt way of specifying what would in effect be a window-to-viewport transform between the application geometry bounds and the TiKZ drawing bounds?

I can see I can use:


to set distance units and:


parameter, but I suspect there's a better way.

Any advice is much appreciated,

  • 5
    Could you give a few more details? TikZ works out the bounding box as it goes along so it's not clear what you need to specify. Yes, you could get TikZ to change the distance units and the scale but then you could presumably also get the generating program to multiply all coordinates appropriately, so it's not clear to me what you need TikZ to do here. Commented Aug 6, 2012 at 9:40
  • Good point. I didn't make it clear that the geometry I want to draw is defined in its own "world" coordinate system, which changes from instance to instance. That's why I was looking for something like a world-to-viewport coordinates transform in TiKZ (which may not be a sensible use of TikZ). Commented Aug 6, 2012 at 22:56

1 Answer 1


I'm not sure this is what your looking for, but probably you want something like this:






[   x={(\xx cm,\xy cm)},
    y={(\yx cm,\yy cm)},
    z={(\zx cm,\zy cm)},
\draw[-latex,red] (-1,0,0) -- (3.5,0,0) node[label=\xangle:x] {};
\draw[-latex,blue] (0,-1,0) -- (0,3.5,0) node[label=\yangle:y] {};
\draw[-latex,black] (0,0,-1) -- (0,0,3.5) node[label=\zangle:z] {};

\foreach \c in {-1,...,3}
{   \fill[red] (\c,0,0) circle (0.05cm);
    \fill[blue] (0,\c,0) circle (0.05cm);
    \fill[black] (0,0,\c) circle (0.05cm);


enter image description here

You can specify all axes as x={(x-component,y-component)}. In this example you can specify the angle in which a coordinate axis points (xangle) and it's length (xlength). From this, the components are automatically computed. In the options for the TikZ picture I wrote \xx cm, otherwise TikZ will assume the measures are given in points, thus resulting in a very tiny picture. Try playing around with the xyzangles and xyzlengths to see the picture change.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .