turtle.setworldcoordinates() function in Python
Last Updated :
25 Aug, 2025
turtle.setworldcoordinates() sets a custom coordinate system for the turtle graphics window. Unlike the default pixel-based system, it lets you define any range of coordinates. Calling it resets the screen, if the mode is already "world", existing drawings are redrawn to fit the new coordinates.
Syntax
turtle.setworldcoordinates(llx, lly, urx, ury)
Parameter:
- llx: (number), x-coordinate of the lower-left corner of the canvas.
- lly: (number), y-coordinate of the lower-left corner of the canvas.
- urx : (number), x-coordinate of the upper-right corner of the canvas.
- ury : (number), y-coordinate of the upper-right corner of the canvas.
Examples
Example 1: Using small world coordinates
Python
import turtle
sc = turtle.Screen()
sc.mode('world')
turtle.setworldcoordinates(-20, -20, 20, 20)
for i in range(20):
turtle.forward(1 + 1*i)
turtle.right(90)
turtle.done()
Output:
Part AExplanation: The coordinates are set between -20 and 20, so the drawing looks zoomed in and larger relative to the screen.
Example 2: Larger world coordinates
Python
import turtle
sc = turtle.Screen()
sc.mode('world')
# set larger world coordinates
turtle.setworldcoordinates(-40, -40, 40, 40)
for i in range(20):
turtle.forward(1 + 1*i)
turtle.right(90)
turtle.done()
Output :

Explanation: With coordinates expanded to -40 to 40, the same drawing appears smaller and more compact.
Example 3 : Updating world coordinates multiple times
Python
import turtle
sc = turtle.Screen()
sc.mode('world')
# first set of coordinates
turtle.setworldcoordinates(-50, -50, 50, 50)
for i in range(16):
turtle.forward(1 + 1*i)
turtle.right(90)
# update coordinates
turtle.setworldcoordinates(-40, -40, 40, 40)
for i in range(16):
turtle.forward(1 + 1*(i+16))
turtle.right(90)
# update coordinates again
turtle.setworldcoordinates(-30, -30, 30, 30)
for i in range(16):
turtle.forward(1 + 1*(i+32))
turtle.right(90)
turtle.done()
Output :

Explanation: Each time the world coordinates shrink, the existing drawing is rescaled and the turtle continues, making shapes appear progressively smaller.
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice