Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the function of drawing circles with python

Shulou Source: shulou.com Published: 2022-05-31 10:45:17 09月23日 Update

This article Xiaobian for you to introduce in detail "how to achieve python circle function", the content is detailed, the steps are clear, the details are handled properly, I hope this "how to achieve python circle function" article can help you solve your doubts, the following follow the editor's ideas slowly in depth, together to learn new knowledge.

Effect:

Import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Polygon import matplotlib.patches as mpatches fig = plt.figure (figsize = (16 np.pi,np.pi,100 8)) ax = fig.gca () ax.set_xlim (- 5LJ 18) ax.set_ylim (- 5L8) 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 (T [I])) y.append (r*np.sin (T [I])) r color 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 (T [I])); y.append (r*np.sin (T [I])) x = np.array (x) Y = np.array (y) verts = list (zip (xgramsx)) poly = Polygon (verts, facecolor=c, edgecolor=c) ax.add_patch (poly) # ppp. 0) def get_coordiate (xmemy): beta = (Alpha [y] + alpha [y]) / 2 pr = 0.5* (x+x-1) / 2 sx = pr*np.cos (beta) Sy = pr*np.sin (beta) return sx,sy def pp_arrow (xPowery): print XMagi y sx,sy = get_coordiate (XMagi y) for i in range (- 1Magazine 2): for j in range (- 1Mae 2): if I = = 0 and j = = 0: continue ex, ey = get_coordiate (xonomi, ypenj) 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) pxy (13) mr = np.zeros (10)) mb = np.zeros (10) for i in range (3): for j in range (1) if ttt: ttt = np.random.random () if ttt > = 0.98 and ttt ma: ma = ttt posx = k Posy = s ppp (i+posx, j+posy,'r', 13 ax.add_patch 0) ppp (iLJ) for i in range (10): for j in range (30): if mb [I] [j] = 0: continue ppp (iLJ) [b', 13) arrow = mpatches.Arrow (5,0,3) ax.add_patch width = 1 (arrow) 'after one\ nunit time',ha='center',va='center',color='y') xx = [4Power4] yy = [7.5Power6.5] c = [' b', 'rpm,' 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 and 0.3 Ec = c [I], fc=c [I]) ax.text (xx [I] + 0.7 off' yy [I], s [I]) ax.add_patch (rect) plt.axis ('off') plt.show () here This article "how to achieve the python circle function" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about the article, you are welcome to pay attention to the industry information channel.

Tags: Functions articles content appropriateness ideas effects new knowledge more steps knowledge knowledge points articles details industry information information channels follow channels processing learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi Docker OPPO Reno Linux