时间:2021-05-22
如下所示:
import numpy as np import matplotlib.pyplot as pltimport matplotlib.patches as mpatchesfrom scipy import stats fig = plt.figure()ax = fig.add_subplot(111, xlim=(0, 10), ylim=(-4, 4))sx=0;sy=0;r=1.5 ; circle = mpatches.Circle((sx,sy),r,ec='b',fc = 'b',alpha=0.6)ax.add_patch(circle)n = 5alpha = np.linspace(-np.pi/2,np.pi/2,100)for i in range(1,n+1): a = (i+1)*2 b = (i+1) plt.plot(a*np.cos(alpha),b*np.sin(alpha)) if i <= 3: ax.text(a+1,0,'layer.%d'%(i-1),ha='center',va='center')rate = 3Jnum = 100for i in range(Jnum): data = stats.poisson.rvs(mu = rate, loc = 0 , size = 1) while data == 0: data = stats.poisson.rvs(mu = rate, loc = 0 , size = 1) data = data[0] r = np.random.random() beta = (np.random.random()-0.5)*np.pi print beta data += r a = (data+1)*2*np.cos(beta) b = (data+1)*np.sin(beta) ax.scatter(a,b, c='y',edgecolors = 'y')xx = [3.5 , 6.8,6.8]yy = [-1.8,0.9,3.1]pp = [1.00,0.85,0.75]rota = [-45,0,0]for i in range(3): plt.plot((1.5,xx[i]) , (0,yy[i]) , 'r') ax.scatter(xx[i],yy[i], c='y',edgecolors = 'b') ax.text(xx[i] , yy[i] , 'probability %lf'%pp[i] , ha = 'center' )tx = np.linspace(0,10,10)ty = np.linspace(-4,-4,10)ax.set_xticks(tx)ax.set_xticklabels((''))ax.set_yticks(ty)ax.set_yticklabels((''))#plt.axis('off')plt.show()以上这篇使用python 的matplotlib 画轨道实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了Python使用matplotlib模块scatter方法画散点图。分享给大家供大家参考,具体如下:#-*-coding:utf-8-*-impo
本文实例讲述了Python基于matplotlib画箱体图检验异常值操作。分享给大家供大家参考,具体如下:#-*-coding:utf-8-*-#!python
本文实例为大家分享了python使用matplotlib画柱状图、散点图的具体代码,供大家参考,具体内容如下柱状图(plt.bar)代码与注释importnum
本文实例讲述了Python基于Matplotlib库简单绘制折线图的方法。分享给大家供大家参考,具体如下:Matplotlib画折线图,有一些离散点,想看看这些
本文实例讲述了Python使用matplotlib画矩形的三种方式。分享给大家供大家参考,具体如下:假设矩形两点坐标如下,分别为:x1,y1,x2,y2cat_