欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡(jiǎn)單實(shí)現(xiàn)python畫(huà)圓功能

 更新時(shí)間:2018年01月25日 13:41:18   作者:ijbuhv  
這篇文章主要為大家詳細(xì)介紹了簡(jiǎn)單實(shí)現(xiàn)python畫(huà)圓功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了python實(shí)現(xiàn)畫(huà)圓功能的具體代碼,供大家參考,具體內(nèi)容如下

import numpy as np 
import matplotlib.pyplot as plt 
from matplotlib.patches import Polygon 
import matplotlib.patches as mpatches 
 
fig = plt.figure(figsize = (16,8)) 
ax = fig.gca() 
ax.set_xlim(-5,18) 
ax.set_ylim(-5,8) 
alpha = np.linspace(-np.pi,np.pi,30)  
t = np.linspace(-np.pi,np.pi,100) 
def ppp(nc , na , c , sx , sy): 
 beta = alpha[na] 
 gam = alpha[na+1] 
 x = [] ; y = [] ; 
 r = 0.5*nc 
 x.append(r*np.cos(beta)) ; y.append(r*np.sin(beta)) ; 
 tt = np.linspace(beta,gam,10) 
 for i in range(len(tt)): 
  x.append(r*np.cos(tt[i])) 
  y.append(r*np.sin(tt[i])) 
 r-=0.5 
 x.append(r*np.cos(gam)) ; y.append(r*np.sin(gam)) 
 tt = np.linspace(gam,beta,10) 
 for i in range(len(tt)): 
  x.append(r*np.cos(tt[i])) ; y.append(r*np.sin(tt[i])) 
 x = np.array(x) ; y = np.array(y) 
 verts = list(zip(x+sx,y+sy)) 
 poly = Polygon(verts , facecolor=c , edgecolor=c) 
 ax.add_patch(poly) 
 
#ppp(2,0,'r',0,0) 
def get_coordiate(x , y): 
 beta = (alpha[y]+alpha[y+1])/2 
 pr = 0.5*(x+x-1)/2 
 sx = pr*np.cos(beta) ; sy = pr*np.sin(beta) 
 return sx,sy 
def pp_arrow(x,y): 
 print x , y 
 sx , sy = get_coordiate(x, y) 
 for i in range(-1,2): 
  for j in range(-1,2): 
   if i == 0 and j == 0: 
    continue 
   ex , ey = get_coordiate(x+i, y+j) 
   ax.arrow(sx,sy,ex-sx,ey-sy,head_width=0.05,head_length=0.1,fc='r',ec='r') 
    
def pxy(cx,cy): 
 for i in range(10): 
  plt.plot(0.5*i*np.cos(t)+cx,0.5*i*np.sin(t)+cy)  
 for i in range(len(alpha)): 
  plt.plot((0.5*np.cos(alpha)+cx,4.5*np.cos(alpha)+cx),(0.5*np.sin(alpha)+cy,4.5*np.sin(alpha)+cy)) 
 
cx = 13 ; cy =0 
pxy(0,0) 
pxy(13,0) 
 
mr = np.zeros((10,30)) 
mb = np.zeros((10,30)) 
 
for i in range(3,9): 
 for j in range(1,27): 
  ttt = np.random.random() 
  if ttt >= 0.98 and ttt <= 1: 
   ppp(i,j,'r',0,0) 
   mr[i][j] = 1 
   continue 
  if ttt < 0.8: 
   continue 
  else: 
   ppp(i,j,'b',0,0) 
   mb[i][j] = 1 
 
for i in range(10): 
 for j in range(30): 
  if mr[i][j] == 0: 
   continue 
  pp_arrow(i, j) 
  ma = 0 ;posx = 1 ; posy = 1 
  for k in range(-1,2): 
   for s in range(-1,2): 
    mb[i+k][j+s]=0 
    ttt = np.random.random() 
    if ttt > ma: 
     ma = ttt 
     posx = k ; posy = s 
  ppp(i+posx , j+posy , 'r' , 13 , 0) 
  ppp(i,j,'g',13,0) 
 
for i in range(10): 
 for j in range(30): 
  if mb[i][j] == 0: 
   continue 
  ppp(i , j , 'b' , 13 , 0) 
 
arrow = mpatches.Arrow(5, 0 
      ,3,0,width = 1,color = 'r') 
ax.add_patch(arrow) 
ax.text(6.2,0.5,'after one\nunit time',ha='center',va='center',color='y') 
 
xx = [4,4,4] 
yy = [7.5,6.5,5.5] 
c = ['b' , 'r' , 'g'] 
s = ['debris','satellite' , 'the location of satellite one unit time ago'] 
for i in range(3): 
 print xx[i] , yy[i] 
 rect = mpatches.Rectangle((xx[i],yy[i]),0.5,0.3,ec = c[i],fc=c[i] ) 
 ax.text(xx[i]+0.7,yy[i],s[i]) 
 ax.add_patch(rect) 
plt.axis('off') 
plt.show() 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • python 使用openpyxl讀取excel數(shù)據(jù)

    python 使用openpyxl讀取excel數(shù)據(jù)

    這篇文章主要介紹了python 使用openpyxl讀取excel數(shù)據(jù)的方法,幫助大家更好的理解和學(xué)習(xí)使用python,感興趣的朋友可以了解下
    2021-02-02
  • python使用遞歸的方式建立二叉樹(shù)

    python使用遞歸的方式建立二叉樹(shù)

    這篇文章主要介紹了python使用遞歸的方式建立二叉樹(shù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • Python繪制數(shù)據(jù)圖表的超詳細(xì)教程

    Python繪制數(shù)據(jù)圖表的超詳細(xì)教程

    畫(huà)一個(gè)吸引人注意的圖表相當(dāng)重要,當(dāng)你探索一個(gè)數(shù)據(jù)集,需要畫(huà)圖表,圖表看起來(lái)令人愉悅是件很高興的事,下面這篇文章主要給大家介紹了關(guān)于Python繪制數(shù)據(jù)圖表的超詳細(xì)教程,需要的朋友可以參考下
    2022-11-11
  • python已協(xié)程方式處理任務(wù)實(shí)現(xiàn)過(guò)程

    python已協(xié)程方式處理任務(wù)實(shí)現(xiàn)過(guò)程

    這篇文章主要介紹了python已協(xié)程方式處理任務(wù)實(shí)現(xiàn)過(guò)程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • Python網(wǎng)絡(luò)安全格式字符串漏洞任意地址覆蓋大數(shù)字詳解

    Python網(wǎng)絡(luò)安全格式字符串漏洞任意地址覆蓋大數(shù)字詳解

    這篇文章主要介紹了Python網(wǎng)絡(luò)安全格式字符串漏洞任意地址覆蓋大數(shù)字的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2021-10-10
  • Pycharm導(dǎo)入Python包,模塊的圖文教程

    Pycharm導(dǎo)入Python包,模塊的圖文教程

    今天小編就為大家分享一篇Pycharm導(dǎo)入Python包,模塊的圖文教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06
  • python自動(dòng)發(fā)送測(cè)試報(bào)告郵件功能的實(shí)現(xiàn)

    python自動(dòng)發(fā)送測(cè)試報(bào)告郵件功能的實(shí)現(xiàn)

    這篇文章主要介紹了python自動(dòng)發(fā)測(cè)試報(bào)告郵件功能的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • 記錄Python腳本的運(yùn)行日志的方法

    記錄Python腳本的運(yùn)行日志的方法

    這篇文章主要介紹了記錄Python腳本的運(yùn)行日志的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • 使用Django+Vue編寫(xiě)一個(gè)文件上傳器

    使用Django+Vue編寫(xiě)一個(gè)文件上傳器

    本教程中,我將會(huì)使用Django和Vue創(chuàng)建一個(gè)支持多文件上傳的文件上傳器,您可以在單個(gè)文件和多個(gè)文件上傳之間選擇在應(yīng)用中進(jìn)行上傳操作,文章通過(guò)代碼示例截殺的非常詳細(xì),需要的朋友可以參考下
    2023-11-11
  • python與xml數(shù)據(jù)的交互詳解

    python與xml數(shù)據(jù)的交互詳解

    這篇文章主要介紹了python與xml數(shù)據(jù)的交互詳解,文章圍繞主題站卡詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-07-07

最新評(píng)論