matplotlib(4 繪製球員能力面板)

2021-10-01 12:57:55 字數 1970 閱讀 6661

# -*- coding: utf-8 -*-

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

from matplotlib.font_manager import fontproperties

font = fontproperties(fname=r'c:\windows\fonts\simsun.ttc'

, size=12)

ability_label =

[u'進攻'

, u'防守'

, u'盤帶'

, u'速度'

, u'體力'

, u'射術'

]ability_size =

6# 隨機生成球員資料

player =

# 生成角度值,各個角度一樣

theta = np.linspace(0,

2* np.pi,

6, endpoint=

false

)# 追加乙個值使得首尾連線0]

)# 追加乙個值使得首尾連線

player[

'm']

'm']

, player[

'm'][0

])player[

'n']

'n']

, player[

'n'][0

])player[

'h']

'h']

, player[

'h'][0

])player[

'q']

'q']

, player[

'q'][0

])plt.style.use(

'ggplot'

)ax1 = plt.subplot(

221, projection=

'polar'

)ax2 = plt.subplot(

222, projection=

'polar'

)ax3 = plt.subplot(

223, projection=

'polar'

)ax4 = plt.subplot(

224, projection=

'polar'

)# 座標系:ax,座標角度:theta,球員資料:player,球員名字:p_name,顯示顏色:color

defset_ax

(ax, theta, player, p_name, color)

: ax.fill(theta, player, color, alpha=

0.3)

ax.set_xticks(theta)

ax.set_xticklabels(ability_label, y=

-0.05

, fontproperties=font)

ax.set_title(p_name, fontproperties=font, color=color, size=20)

ax.set_yticks(

)set_ax(ax1, theta, player[

'm']

,'球員a'

,'r'

)set_ax(ax2, theta, player[

'n']

,'球員b'

,'g'

)set_ax(ax3, theta, player[

'h']

,'球員c'

,'b'

)set_ax(ax4, theta, player[

'q']

,'球員d'

matplotlib繪製等直線

利用contour contourf 描繪等值線 contourf 帶有填充效果 def fig2 y,x np.ogrid 2 2 200j,3 3 300j z x np.exp x 2 y 2 extent np.min x np.max x np.min y np.max y plt.fig...

Python使用matplotlib繪製三維曲線

本文主要演示如何使用matplotlib繪製三維圖形 如下 coding utf 8 import matplotlib as mpl from mpl toolkits.mplot3d import axes3d import numpy as np import matplotlib.pyplo...

python之matplotlib繪製散點

使用scatter 繪製散點圖 隨意給出一些點 x train np.array 3.3 4.4 5.5 6.71 6.93 4.168 9.776 6.182 7.59 2.167 dtype np.float32 y train np.array 1.7 2.76 2.09 3.19 1.694...