日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

实例

發布時間:2024/7/5 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 函數積分圖
  • 散點條形圖
  • 球員能力值

函數積分圖

import matplotlib.pyplot as plt import numpy as np from matplotlib.pyplot import Polygon def func(x):return -(x-2)*(x-8)+40 x=np.linspace(0,10) y=func(x) ax=plt.subplot() plt.plot(x,y,'r',linewidth=2)a=2 b=9 ax.set_xticks([a,b]) ax.set_yticks([]) ax.set_xticklabels([r'$a$',r'$b$']) ix=np.linspace(a,b) iy=func(ix) #陰影 ixy=zip(ix,iy) verts=[(a,0)]+list(ixy)+[(b,0)] poly=Polygon(verts,facecolor='0.5',edgecolor='0.1') ax.add_patch(poly)plt.figtext(0.9,0.05,'$x$') plt.figtext(0.1,0.9,'$y$') x_match=(a+b)*0.5*0.7 y_match=35 #公式 plt.text(x_match,y_match,r'$\int_a^b(-(x-2)*(x-8)+40dx$',fontsize=15,horizontalalignment='center') plt.show()

散點條形圖

import matplotlib.pyplot as plt import numpy as np plt.style.use('ggplot') x=np.random.randn(200) y=x+np.random.randn(200)*0.5 #構圖 margin_border=0.1 width=0.6 margin_between=0.02 height=0.2left_s=margin_border bottom_s=margin_border height_s=width width_s=widthleft_x=margin_border bottom_x=margin_border+width+margin_between height_x=height width_x=widthleft_y=margin_border+width+margin_between bottom_y=margin_border height_y=width width_y=heightplt.figure(1,figsize=(8,8))#散點圖,制出基本構造 rect_s=[left_s,bottom_s,width_s,height_s] rect_x=[left_x,bottom_x,width_x,height_x] rect_y=[left_y,bottom_y,width_y,height_y]axScatter=plt.axes(rect_s) axHisX=plt.axes(rect_x) axHisY=plt.axes(rect_y) #去坐標軸 axHisX.set_xticks([]) axHisY.set_yticks([]) #繪圖 axScatter.scatter(x,y) bin_width=0.25 xymax=np.max([np.max(np.fabs(x)),np.max(np.fabs(y))]) lim=int(xymax/bin_width+1)*bin_widthaxScatter.set_xlim(-lim,lim) axScatter.set_ylim(-lim,lim)bins=np.arange(-lim,lim+bin_width)axHisX.hist(x,bins=bins) axHisY.hist(y,bins=bins,orientation='horizontal')axHisX.set_xlim(axScatter.get_xlim()) axHisY.set_xlim(axScatter.get_ylim())plt.show()

球員能力值

import matplotlib.pyplot as plt import numpy as np from matplotlib.font_manager import FontPropertiesfont = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12) plt.style.use('ggplot') ax1=plt.subplot(111,projection='polar') ability_size=6 ability_label=[u'進攻',u'防守',u'盤帶',u'速度',u'體力',u'射術',]player={'M':np.random.randint(size=ability_size,low=80,high=99)}#使其閉環 theta=np.linspace(0,2*np.pi,6,endpoint=False) theta=np.append(theta,theta[0])player['M']=np.append(player['M'],player['M'][0]) ax1.plot(theta,player['M'],'r') ax1.fill(theta,player['M'],'r',alpha=0.3) ax1.set_xticks(theta) ax1.set_xticklabels(ability_label,y=0.01,fontproperties=font) ax1.set_title(u'梅西',fontproperties=font,color='r',size=20) plt.show()

總結

以上是生活随笔為你收集整理的实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。