當前位置:首頁 » 玫丹百香 » python中turtle畫玫瑰

python中turtle畫玫瑰

發布時間: 2021-02-17 06:21:34

❶ 用Python matplotlib 怎麼畫風向玫瑰圖 能給出程序的

需要提前安裝windrose模塊


importmatplotlib.cmascm
fromnumpy.randomimportrandom
fromnumpyimportarange
ws=random(500)*6
wd=random(500)*360
#...
defnew_axes():
fig=plt.figure(figsize=(8,8),dpi=80,facecolor='w',edgecolor='w')
rect=[0.1,0.1,0.8,0.8]
ax=WindroseAxes(fig,rect,axisbg='w')
fig.add_axes(ax)
returnax
#...andadjustthelegendbox
defset_legend(ax):
l=ax.legend(shadow=True,bbox_to_anchor=[-0.1,0],loc='lowerleft')
plt.setp(l.get_texts(),fontsize=10)

ax=new_axes()
ax.bar(wd,ws,normed=True,opening=0.8,edgecolor='white')
set_legend(ax)
plt.show()

❷ 如何用python turtle畫心

是要表白么,嘿嘿,希望這個代碼能幫到你哦~(參數不滿意可以自己調)

importturtle
importmath
wn=turtle.Screen()
wn.setworldcoordinates(-2,-2,2,2)
alex=turtle.Turtle()
alex.color("red")
alex.pensize(2)
alex.penup()
alex.speed(0)
walkStart=-1
walkEnd=1
i=walkStart
j=walkEnd
whilei<=0andj>=0:
y1=math.sqrt(1-i*i)+(i*i)**(1/3.0)
y2=-math.sqrt(1-i*i)+(i*i)**(1/3.0)
y3=math.sqrt(1-j*j)+(j*j)**(1/3.0)
y4=-math.sqrt(1-j*j)+(j*j)**(1/3.0)
alex.setx(i)
alex.sety(y1)
alex.dot()
alex.sety(y2)
alex.dot()
alex.setx(j)
alex.sety(y3)
alex.dot()
alex.sety(y4)
alex.dot()
i+=0.01
j-=0.01
wn.exitonclick()

❸ 如何把python繪制的玫瑰隨機生成多個玫瑰

import random
random.choice((1, 2, 3))

❹ 怎麼用python的turtle庫畫出這個圖案,要代碼

import turtle as t


def quad(color):

t.begin_fill()

t.color(color)

t.forward(100)

t.left(36)

t.forward(100)

t.left(36*4)

t.forward(100)

t.left(36)

t.forward(100)

t.end_fill()

t.left(36*3)



for i in range(10):

if i%2:

quad('#99c8de')

else:

quad('#e5b9c4')

兩三年沒碰海龜了,覺得沒啥用,看你賞金又提專了就回去屬學了學

❺ python的turtle怎麼畫曲線

turtle.circle()畫圓

Turtle庫是Python語言中一個很流行的繪制圖像的函數庫,想像一個小烏龜,在一個橫軸為專x、縱軸為y的坐標系原屬點,(0,0)位置開始,它根據一組函數指令的控制,在這個平面坐標系中移動,從而在它爬行的路徑上繪制了圖形。

❻ 怎麼用python畫玫瑰花,求大神貼代碼,感激不盡

importturtle

#設置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)

#花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10,180)
turtle.circle(25,110)
turtle.left(50)
turtle.circle(60,45)
turtle.circle(20,170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30,110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90,70)
turtle.circle(30,150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80,90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150,80)
turtle.left(50)
turtle.circle(150,90)
turtle.end_fill()

#花瓣1
turtle.left(150)
turtle.circle(-90,70)
turtle.left(20)
turtle.circle(75,105)
turtle.setheading(60)
turtle.circle(80,98)
turtle.circle(-90,40)

#花瓣2
turtle.left(180)
turtle.circle(90,40)
turtle.circle(-80,98)
turtle.setheading(-83)

#葉子
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80,90)
turtle.right(90)
turtle.circle(-80,90)
turtle.end_fill()

turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)

#葉子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80,90)
turtle.left(90)
turtle.circle(80,90)
turtle.end_fill()

turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200,60)

運行結果:

❼ python怎麼畫玫瑰花

操縱海龜繪圖有著許多的命令,這些命令可以劃分為兩種:一種為運動命令,一種為畫筆控制命令
1. 運動命令:
forward(degree) #向前移動距離degree代表距離
backward(degree) #向後移動距離degree代表距離
right(degree) #向右移動多少度
left(degree) #向左移動多少度
goto(x,y) #將畫筆移動到坐標為x,y的位置
stamp() #復制當前圖形
speed(speed) #畫筆繪制的速度范圍[0,10]整數

2. 畫筆控制命令:
down() #移動時繪制圖形,預設時也為繪制
up() #移動時不繪制圖形
pensize(width) #繪制圖形時的寬度
color(colorstring) #繪制圖形時的顏色
fillcolor(colorstring) #繪制圖形的填充顏色
fill(Ture)
fill(false)

lucy : 夢想照進現實;露茜;青春風采;

draw_flower1.py

[python]view plain

  • #-*-coding:cp936-*-

  • importturtle

  • importmath

  • defp_line(t,n,length,angle):

  • """Drawsnlinesegments."""

  • foriinrange(n):

  • t.fd(length)

  • t.lt(angle)

  • defpolygon(t,n,length):

  • """Drawsapolygonwithnsides."""

  • angle=360/n

  • p_line(t,n,length,angle)

  • defarc(t,r,angle):

  • """."""

  • arc_length=2*math.pi*r*abs(angle)/360

  • n=int(arc_length/4)+1

  • step_length=arc_length/n

  • step_angle=float(angle)/n

  • #Beforestartingreces,makingaslightleftturn.

  • t.lt(step_angle/2)

  • p_line(t,n,step_length,step_angle)

  • t.rt(step_angle/2)

  • defpetal(t,r,angle):

  • """Drawsa花瓣usingtwoarcs."""

  • foriinrange(2):

  • arc(t,r,angle)

  • t.lt(180-angle)

  • defflower(t,n,r,angle,p):

  • """Drawsaflowerwithnpetals."""

  • foriinrange(n):

  • petal(t,r,angle)

  • t.lt(p/n)

  • defleaf(t,r,angle,p):

  • """Drawsa葉子andfillit."""

  • t.begin_fill()#Beginthefillprocess.

  • t.down()

  • flower(t,1,40,80,180)

  • t.end_fill()

  • defmain():

  • window=turtle.Screen()#creatascreen

  • window.bgcolor("blue")

  • lucy=turtle.Turtle()

  • lucy.shape("turtle")

  • lucy.color("red")

  • lucy.width(5)

  • lucy.speed(0)

  • #Drawingflower

  • flower(lucy,7,60,100,360)

  • #Drawingpedicel

  • lucy.color("brown")

  • lucy.rt(90)

  • lucy.fd(200)

  • #Drawingleaf

  • lucy.rt(270)

  • lucy.color("green")

  • leaf(lucy,40,80,180)

  • lucy.ht()

  • window.exitonclick()

  • main()

❽ 求問怎樣用python/python turtle畫「心」

importturtle
a=turtle.Turtle()
defdrawlove():
a.left(45)
a.forward(30)
a.right(45)
a.forward(30)
a.right(120)
a.forward(110)
a.penup()
a.right(150)
a.forward(75)
a.pendown()
a.left(45)
a.forward(30)
a.left(45)
a.forward(30)
a.left(120)
a.forward(110)
drawlove()

這是我做的比較粗略的一個

代碼用理解英語的方式理解就好,改下數據做下更專精密的數學計算就好了屬

❾ 用Python matplotlib 怎麼畫風向玫瑰圖 能給出程序的

importnumpyasnp
importmatplotlib.pyplotasplt


N=20
theta=np.linspace(0.0,2*np.pi,N,endpoint=False)
radii=10*np.random.rand(N)
width=np.pi/4*np.random.rand(N)

ax=plt.subplot(111,projection='polar')
bars=ax.bar(theta,radii,width=width,bottom=0.0)

#Usecustomcolorsandopacity
forr,barinzip(radii,bars):
bar.set_facecolor(plt.cm.jet(r/10.))
bar.set_alpha(0.5)

plt.show()

差不多上面代碼的原理,具體的自己照專著官方文屬檔改

❿ 用Python matplotlib 怎麼畫風向玫瑰圖 能給出程序的

軟體包復numpy的安裝:
1 命令行輸入【完整制的路徑=numpy 在你電腦的絕對路徑】
pip install 完整的路徑\numpy -1.10.1+mkl-cp34-none-win_amd64.
2 驗證:python編輯下 python>>
from numpy import *

安裝matplotlib:
matplotlib-1.4.3.win-amd64-py3.4
因為下載的是exe文件,點擊一路執行即可

熱點內容
古詩的七夕 發布:2025-07-28 21:06:56 瀏覽:294
快手秒盆栽 發布:2025-07-28 21:04:32 瀏覽:462
綠植花卉廣告 發布:2025-07-28 21:04:21 瀏覽:128
立金花花語 發布:2025-07-28 21:04:19 瀏覽:813
七夕節中午 發布:2025-07-28 21:02:07 瀏覽:595
彩鉛花卉手繪 發布:2025-07-28 20:57:22 瀏覽:957
玫瑰花的編制 發布:2025-07-28 20:53:55 瀏覽:127
招財盆景圖l 發布:2025-07-28 20:53:43 瀏覽:411
綠植小分享 發布:2025-07-28 20:48:36 瀏覽:378
中國人過幾個情人節 發布:2025-07-28 20:47:59 瀏覽:365