I want to draw a line.
Graphics[{Line[{{0, 0}, {10, 0}}]}]
Out
Note that changing the end point does not affect the displayed line.
Graphics[{Line[{{0, 0}, {20, 0}}]}]
Out
But I want to draw a longer line. How to do it?
While the scale answer is technically correct, what you really are trying to do, is to prevent the background from continually resizing to accommodate graphical contents.
The option you want is PlotRange->{{Xmin,Xmax},{Ymin,Ymax}}
(optionally, Zmin,Zmax for 3D graphics. Another 2 options which affect the output size are ImageSize
and AspectRatio
. One scales the whole graphic, another "squishes" the graphic to accommodate a given Y:X ratio. So AspectRatio->2
would give you a vertical rectangle, and AspectRatio->1/2
- a horizontal one, while AspectRatio->1
is a perfect square.
Try this:
Graphics[{
(* your graphics directives here *)
}, PlotRange->{{0,50},{0,50}}, AspectRatio->1, ImageSize->800]
Enjoy!
If you have to draw only one line, then it will be automatically scaled as in your example. You can make this line bigger by clicking on the image and make the borders bigger with the mouse...
If you draw two lines then you will see the correct result (ratio)
Graphics[{Scale[Line[{{0, 0}, {10, 0}}], 3], Line[{{0, 1}, {10, 1}}]}]
in the example above the first line can be scaled
Frame -> True
at the end ofGraphics
to see what happens. Look upImageSize
andAspectRatio
to control the graphics size and shape. $\endgroup$Manipulate[ Graphics[{Line[{{0, 0}, {x, 0}}]}, ImageSize -> 72*x], {{x, 1}, 1, 5, Appearance -> "Labeled"}]
$\endgroup$