We’ve used ListPlot and ListLinePlot to plot lists of values, where each value appears after the one before. But by giving lists containing pairs of coordinates instead of single values, we can use these functions to plot points at arbitrary positions.

ListPlot[{4,3,2,1,1,1,1,2,3,4}]

ListLinePlot[{{1,1},{1,5},{6,4},{6,2},{2,3},{5,5}}]

The position of each point here is specified by {x, y} coordinates. Following the standard convention in mathematics, the x value says how far across horizontally the point should be; the y value says how far up vertically it should be.

Table[RandomInteger[20],10,2]

RandomInteger[20,{10,2}]

ListPlot[Table[RandomInteger[1000],100,2]]

We can use coordinates to construct graphics. Earlier we saw how to make graphics of one circle. To make graphics of more than one circle we have to say where each circle is, which we can do by giving the coordinates of their centers.

Graphics[{Circle[{1,1}],Circle[{1,2}],Circle[{3,1}]}]

Graphics[{Style[Circle[{1,1}],Red],Style[Circle[{1,2}],Green],Style[Circle[{3,1}],Blue]}]

Graphics[Table[Circle[RandomInteger[50,2]],100]]

Graphics[Table[Circle[{x,y}],{x,0,10,2},{y,0,10,2}]]

Circle[{x,y}] means a circle centered at position {x,y}. If you don’t say otherwise, the circle is given radius 1. You can make a circle of any radius using Circle[{x,y},r].

Graphics[{Circle[{1,1},0.5],Circle[{1,2},1.2],Circle[{3,1},0.8]}]

Graphics[Table[Circle[{0,0},r],{r,10}]]

Graphics[Table[Circle[{x,0},x],{x,10}]]

Graphics[Table[Circle[RandomInteger[50,2],RandomInteger[10]],100]]

RegularPolygon works much the same as Circle and Disk, except that in addition to giving the position of the center and the size, you also have to specify how many sides the polygon should have.

Graphics[{RegularPolygon[{1,1},1,5],RegularPolygon[{3,1},0.5,7]}]

Graphics[{RegularPolygon[{1,1},1,5],Circle[{1,1},1],RegularPolygon[{3,1},.5,7],Disk[{2,2},.5]}]

To make arbitrary graphics, you need the basic graphics primitives Point, Line and Polygon. Point[{x,y}] represents a point at coordinate position {x,y}. To get multiple points, you can either give a list of Point[{x,y}]s, or you can give a list of coordinate positions inside a single Point.

Graphics[{Point[{0,0}],Point[{2,0}],Point[{1,1.5}]}]

Graphics[Point[{{0,0},{2,0},{1,1.5}}]]

Graphics[Line[{{0,0},{2,0},{1,1.5}}]]

Graphics[Polygon[{{0,0},{2,0},{1,1.5}}]]

RegularPolygon makes a regular polygon in which all sides and angles are the same. Polygon lets you make any polygon, even strange ones that fold over themselves.

Graphics[Polygon[Table[RandomInteger[100],20,2]]]

The things we’ve done so far here immediately generalize to 3D. Instead of having two coordinates {x, y} we have three: {x, y, z}. In the Wolfram Language, x by default goes across the screen, y goes “into” the screen, and z goes up the screen.

Graphics3D[{Sphere[{0,0,0}],Sphere[{0,0,2}]}]

Graphics3D[Table[Sphere[{x,y,z},1/2],{x,5},{y,5},{z,5}]]

Graphics3D[Table[Point[{x,y,z}],{x,10},{y,10},{z,10}]]

Graphics3D[Table[Sphere[RandomInteger[10,3]],50]]

If you don’t say otherwise, 3D objects like spheres are drawn solid, so you can’t see through them. But just like you can specify what color something is, you can also specify its opacity. Opacity 1 means completely opaque, so you can’t see through it at all; opacity 0 means completely transparent.

Graphics3D[Table[Style[Sphere[RandomInteger[10,3]],Opacity[0.5]],50]]

You can use Manipulate to make graphics—in 2D or 3D—that can be manipulated.

Manipulate[Graphics3D[{Sphere[{0,0,0}],Style[Sphere[{x,0,0}],Opacity[o]]}],{x,1,3},{o,0.5,1}]

Make graphics of 5 concentric circles centered at {0,0} with radii 1, 2, ... , 5. »

Make 10 concentric circles with random colors. »

Make graphics of a 10×10 grid of circles with radius 1 centered at integer points {x,y}. »

Make a 10×10 grid of points with coordinates at integer positions up to 10. »

Make a Manipulate with between 1 and 20 concentric circles. »

Place 50 spheres with random colors at random integer coordinates up to 10. »

Make a 10×10×10 array of spheres with RGB components ranging from 0 to 1. The spheres should be centered at integer coordinates, and should just touch each other. »

Make a Manipulate with t varying between −2 and +2 that contains circles of radius x centered at {t*x,0} with x going from 1 to 10. »

Make a 5×5 array of regular hexagons with size 1/2, centered at integer points. »

Make a line in 3D that goes through 50 random points with integer coordinates randomly chosen up to 50. »

Make a Manipulate to create an n×n regular grid of points at integer positions, with n going from 5 to 20. »

Place 30 radius-1 circles with random colors at random integer coordinates up to 10. »

Display 100 polygons with side length 10, opacity .5, and random choices of colors, sides between 3 and 8, and integer coordinates up to 100. »

Make a 10×10×10 array of points in 3D, with each point having a random color. »

Take the first two digits of numbers from 10 to 100 and draw a line that uses them as coordinates. »

Take the first 3 digits of numbers from 100 to 1000 and draw a line in 3D that uses them as coordinates. »

What determines the range of coordinates shown?

By default it’s picked automatically, but you can set it explicitly using the PlotRange option, as discussed in Section 20.

How can I put axes on graphics?

Use the option (see Section 20) Axes->True.

How do I change the appearance of the edges of a polygon or disk?

Use EdgeForm inside Style.

What other graphics constructs are there?

Quite a few. Examples include Text (for placing text inside graphics), Arrow (for putting arrowheads on lines, etc.), Inset (for putting graphics inside graphics) and FilledCurve.

How do I get rid of the box around 3D graphics?

Use the option (see Section 20) Boxed->False.

Tech Notes