TwoDimensional Graphics Elements

Point[{x,y}]point at position x, y
Line[{{x1,y1},{x2,y2},}]line through the points , ,
Rectangle[{xmin,ymin},{xmax,ymax}]filled rectangle
Polygon[{{x1,y1},{x2,y2},}]filled polygon with the specified list of corners
Circle[{x,y},r]circle with radius r centered at x, y
Disk[{x,y},r]filled disk with radius r centered at x, y
Raster[{{a11,a12,},{a21,},}]rectangular array of gray levels between 0 and 1
Text[expr,{x,y}]the text of expr, centered at x, y (see "Graphics Primitives for Text")

Basic twodimensional graphics elements.

Here is a line primitive.
In[1]:=
Click for copyable input
Out[1]=
This shows the line as a twodimensional graphics object.
In[2]:=
Click for copyable input
Out[2]=
This redisplays the line, with axes added.
In[3]:=
Click for copyable input
Out[3]=

You can combine graphics objects that you have created explicitly from graphics primitives with ones that are produced by functions like Plot.

This produces an ordinary Wolfram System plot.
In[4]:=
Click for copyable input
Out[4]=
This combines the plot with the sawtooth picture made above.
In[5]:=
Click for copyable input
Out[5]=

You can combine different graphical elements simply by giving them in a list. In twodimensional graphics, the Wolfram System will render the elements in exactly the order you give them. Later elements are therefore effectively drawn on top of earlier ones.

Here are two blue Rectangle graphics elements.
In[6]:=
Click for copyable input
Out[6]=
This draws the rectangles on top of the line that was defined above.
In[7]:=
Click for copyable input
Out[7]=

The Polygon graphics primitive takes a list of , coordinates, corresponding to the corners of a polygon. The Wolfram System joins the last corner with the first one, and then fills the resulting area.

Here are the coordinates of the corners of a regular pentagon.
In[8]:=
Click for copyable input
Out[8]=
This displays the pentagon. With the default choice of aspect ratio, the pentagon looks somewhat squashed.
In[9]:=
Click for copyable input
Out[9]=
Point[{pt1,pt2,}]a multipoint consisting of points at , ,
Line[{line1,line2,}]a multiline consisting of lines , ,
Polygon[{poly1,poly2,}]a multipolygon consisting of polygons , ,

Primitives which can take multiple elements.

A large number of points can be represented by putting a list of coordinates inside of a single Point primitive. Similarly, a large number of lines or polygons can be represented as a list of coordinate lists. This representation is efficient and can generally be rendered more quickly by the Wolfram System front end. Graphics directives such as RGBColor apply uniformly to the entire set of primitives.

This creates a multipolygon based upon the set of coordinates defined previously.
In[10]:=
Click for copyable input
Out[10]=
Here is a multipoint that is colored blue.
In[11]:=
Click for copyable input
Out[11]=
Circle[{x,y},r]a circle with radius r centered at the point
Circle[{x,y},{rx,ry}]an ellipse with semiaxes and
Circle[{x,y},r,{theta1,theta2}]a circular arc
Circle[{x,y},{rx,ry},{theta1,theta2}]an elliptical arc
Disk[{x,y},r], etc.filled disks

Circles and disks.

This shows two circles with radius 2.
In[12]:=
Click for copyable input
Out[12]=
This shows a sequence of disks with progressively larger semiaxes in the direction, and progressively smaller ones in the direction.
In[13]:=
Click for copyable input
Out[13]=

The Wolfram System allows you to generate arcs of circles and segments of ellipses. In both cases, the objects are specified by starting and finishing angles. The angles are measured counterclockwise in radians with zero corresponding to the positive direction.

This draws a 149° wedge centered at the origin.
In[14]:=
Click for copyable input
Out[14]=
Raster[{{a11,a12,},{a21,},}] array of gray levels between 0 and 1
Raster[{{{a11,o11},},}]array of gray levels with opacity between 0 and 1
Raster[{{{r11,g11,b11},},}]array of rgb values between 0 and 1
Raster[{{{r11,g11,b11,o11},},}]array of rgb values with opacity between 0 and 1
Raster[array,{{xmin,ymin},{xmax,ymax}},{zmin,zmax}]array of gray levels between and drawn in the rectangle defined by and

Rasterbased graphics elements.

Here is a 4×4 array of values between 0 and 1.
In[15]:=
Click for copyable input
Out[15]=
This uses the array of values as gray levels in a raster.
In[16]:=
Click for copyable input
Out[16]=
This shows two overlapping copies of the raster.
In[17]:=
Click for copyable input
Out[17]=
The ColorFunction option can be used to change the default way in which a Raster is colored.
In[18]:=
Click for copyable input
Out[18]=