Polygon (shape) Component

(added in version 1.78.00)

The Polygon stimulus allows you to present a wide range of regular geometric shapes. The basic control comes from setting the number of vertices:
  • 2 vertices give a line

  • 3 give a triangle

  • 4 give a rectangle etc.

  • a large number will approximate a circle/ellipse

The size parameter takes two values. For a line only the first is used (then use ori to specify the orientation). For triangles and rectangles the size specifies the height and width as expected. Note that for pentagons upwards, however, the size determines the width/height of the ellipse on which the vertices will fall, rather than the width/height of the vertices themselves (slightly smaller typically).



Everything in a PsychoPy® experiment needs a unique name. The name should contain only letters, numbers and underscores (no punctuation marks or spaces).

start :

The time that the stimulus should first appear. See Defining the onset/duration of components for details.

stop :

Governs the duration for which the stimulus is presented. See Defining the onset/duration of components for details.

shapeline, triangle, rectangle, cross, star, regular polygon

What shape the stimulus is

num verticesint

The number of vertices for your shape (2 gives a line, 3 gives a triangle,… a large number results in a circle/ellipse). It is not (currently) possible to vary the number of vertices dynamically.


How should the stimulus look? Colour, borders, etc.

fill colorcolor

See Color spaces

color spacergb, dkl, lms, hsv

See Color spaces

border colorcolor

See Color spaces

line widthint | float

How wide should the line be? Width is specified in chosen spatial units, see Units for the window and stimuli

opacity :

Vary the transparency, from 0.0 = invisible to 1.0 = opaque


How should the stimulus be laid out? Padding, margins, size, position, etc.


The orientation of the entire patch (texture and mask) in degrees.


The position of the centre of the stimulus, in the units specified by the stimulus or window

size(width, height)

Size of the stimulus on screen

spatial unitsdeg, cm, pix, norm, or inherit from window

See Units for the window and stimuli


Control how the stimulus handles textures.

interpolatelinear, nearest

Should textures be interpolated?

unitsdeg, cm, pix, norm, or inherit from window

See Units for the window and stimuli

See also

API reference for Polygon API reference for Rect API reference for ShapeStim #for arbitrary vertices

Back to top