国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python實現雨滴下落到地面效果

2020-02-15 21:57:17
字體:
來源:轉載
供稿:網友

本文實例為大家分享了python實現雨滴下落到地面效果的具體代碼,供大家參考,具體內容如下

本程序在Windows 64位操作系統下,安裝的是Anaconda3-4.2.0

import numpy as np import matplotlib.pyplot as plt from matplotlib import animation  # New figure with white background fig = plt.figure(figsize=(6,6), facecolor='white')  # New axis over the whole figure, no frame and a 1:1 aspect ratio ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)  # Number of ring n = 50 size_min = 50 size_max = 50 ** 2  # Ring position pos = np.random.uniform(0, 1, (n,2))  # Ring colors color = np.ones((n,4)) * (0,0,0,1) # Alpha color channel geos from 0(transparent) to 1(opaque) color[:,3] = np.linspace(0, 1, n)  # Ring sizes size = np.linspace(size_min, size_max, n)  # Scatter plot scat = ax.scatter(pos[:,0], pos[:,1], s=size, lw=0.5, edgecolors=color, facecolors='None')  # Ensure limits are [0,1] and remove ticks ax.set_xlim(0, 1), ax.set_xticks([]) ax.set_ylim(0, 1), ax.set_yticks([])  def update(frame):   global pos, color, size    # Every ring is made more transparnt   color[:, 3] = np.maximum(0, color[:,3]-1.0/n)    # Each ring is made larger   size += (size_max - size_min) / n    # Reset specific ring   i = frame % 50   pos[i] = np.random.uniform(0, 1, 2)   size[i] = size_min   color[i, 3] = 1    # Update scatter object   scat.set_edgecolors(color)   scat.set_sizes(size)   scat.set_offsets(pos)    # Return the modified object   return scat,  anim = animation.FuncAnimation(fig, update, interval=10, blit=True, frames=200) plt.show() 

效果圖:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴海县| 偏关县| 临夏市| 德惠市| 都昌县| 秦安县| 广饶县| 禹州市| 桦川县| 札达县| 海安县| 古田县| 宣威市| 兰州市| 九龙城区| 濮阳县| 涟水县| 馆陶县| 高尔夫| 乐清市| 聊城市| 新河县| 庆阳市| 修水县| 德格县| 霍林郭勒市| 灵璧县| 什邡市| 靖安县| 仙居县| 綦江县| 安西县| 宁南县| 神农架林区| 麦盖提县| 错那县| 山东省| 湟中县| 牡丹江市| 荔波县| 自治县|