Python Turtle图形覆盖问题求助:仅显示最后一个图形
Hey there! I see the issue you're running into—when you adjust the turtle's shape and move it, only the last shape stays visible, right? Let's break down why this happens and how to fix it.
Why This Is Happening
By default, you're working with a single Turtle object. Every time you call shape(), shapesize(), or move the turtle with goto(), you're modifying that one turtle—it doesn't leave behind the previous shape. Think of it like moving a physical turtle around paper: only where it is now is visible, not every spot it's been.
Solutions to Try
1. Use stamp() to Leave Shape Imprints
The easiest fix is to call stamp() after setting up each shape. This leaves a permanent "stamp" of the turtle's current shape at its position, even when you move the turtle elsewhere.
Here's your modified code with stamp() added:
import turtle t = turtle.Turtle() # First shape t.up() t.goto(-200, -200) t.shape("circle") t.shapesize(2, 1, 1) t.fillcolor("black") t.stamp() # Leave the shape here # Second shape t.up() t.goto(-300, -100) t.shape("circle") t.shapesize(4, 4, 1) t.fillcolor("black") t.stamp() # Leave the shape here # Third shape t.up() t.goto(-100, -100) t.shape("circle") t.shapesize(4, 4, 1) t.fillcolor("black") t.stamp() # Leave the shape here t.hideturtle() # Optional: hide the original turtle since we don't need it anymore turtle.done()
2. Clone the Turtle for Independent Shapes
If you want each shape to be a separate, interactive object (e.g., you might want to move them later), you can create multiple turtle instances by cloning the original:
import turtle # Create base turtle (we'll clone this) base_turtle = turtle.Turtle() base_turtle.hideturtle() # First shape t1 = base_turtle.clone() t1.up() t1.goto(-200, -200) t1.shape("circle") t1.shapesize(2, 1, 1) t1.fillcolor("black") t1.showturtle() # Second shape t2 = base_turtle.clone() t2.up() t2.goto(-300, -100) t2.shape("circle") t2.shapesize(4, 4, 1) t2.fillcolor("black") t2.showturtle() # Third shape t3 = base_turtle.clone() t3.up() t3.goto(-100, -100) t3.shape("circle") t3.shapesize(4, 4, 1) t3.fillcolor("black") t3.showturtle() turtle.done()
3. Draw Circles Directly (For Simple Shapes)
Since you're using circle shapes, you could skip modifying the turtle's shape entirely and just draw filled circles/ellipses with begin_fill() and circle():
import turtle t = turtle.Turtle() # First oval (matches shapesize(2,1)) t.up() t.goto(-200, -200) t.down() t.fillcolor("black") t.begin_fill() t.setheading(0) t.circle(20, 360, 30) # Adjust parameters to match your oval size t.end_fill() # Second circle (matches shapesize(4,4)) t.up() t.goto(-300, -100) t.down() t.begin_fill() t.circle(40) # Radius 40 matches 4x the default turtle size t.end_fill() # Third circle t.up() t.goto(-100, -100) t.down() t.begin_fill() t.circle(40) t.end_fill() turtle.done()
Which Method to Choose?
- Use
stamp()for quick, static shapes that don't need interaction. - Clone turtles if you plan to manipulate each shape individually later.
- Draw directly with
circle()if you don't need to use Turtle's preset shape library.
内容的提问来源于stack exchange,提问作者Isu

