python中四瓣花的填充颜色怎么更改

Python053

python中四瓣花的填充颜色怎么更改,第1张

python中四瓣花的填充颜色更改步骤:

1、首先,使用matplotlib.pyplot.subplots()函数创建一个子图,并设置其尺寸。

2、然后,使用matplotlib.pyplot.fill_between()函数绘制四瓣花,并设置其填充颜色。

3、最后,使用matplotlib.pyplot.show()函数显示图形。

#例题1绘制一个四叶草

import turtle

turtle.color("green","green")

turtle.setheading(90)

turtle.begin_fill()

for i in range(4):

    turtle.circle(-100,180)

    turtle.left(90)

turtle.end_fill()

turtle.done()

#例题2绘制一个四角星

import turtle

turtle.color("yellow","yellow")

turtle.begin_fill()

for i in range(4):

    turtle.circle(100,90)

    turtle.right(180)

turtle.end_fill()

turtle.done()

#例题3绘制一个四叶花瓣

import turtle

turtle.color("pink","pink")

turtle.begin_fill()

turtle.circle(-100,90)

turtle.right(90)

turtle.circle(-100,90)

turtle.circle(100, 90)

turtle.right(90)

turtle.circle(-100, -90)

turtle.right(90)

turtle.circle(-100, 90)

turtle.right(90)

turtle.circle(-100, 90)

turtle.circle(100, 90)

turtle.right(90)

turtle.circle(-100, -90)

turtle.end_fill()

turtle.done()

#例题4输入一个数字,绘制以该数字为边数的正多边形

import turtle

a=int(turtle.textinput("绘制正多边形","请输入边数:"))

turtle.circle(100,360,a)

turtle.done()