具有以下功能:
def plot_radar_analysis(df_team_matches, team=None, gameweek=None, kip=None):
from math import pi
import plotly.express as px
from colors import full_team_colors
gameweeks=range(1,gameweek+1)
df_temp = df_team_matches.loc[(df_team_matches['ForTeam']==team[0])
&(df_team_matches['GameWeek'].isin(gameweeks))]
indicator = df_temp[kip[0]]
R = list(indicator.values)
theta = [('Rodada ' + str(i)) for i in list(df_temp['GameWeek'].values)]
color = full_team_colors[team[0]]
df = pd.DataFrame(dict(
r=R,
theta=theta))
fig = px.line_polar(df, r='r', theta='theta', line_close=True, title=f'{team[0]} - {kip[0]}')
fig.update_polars(angularaxis_type="category")
fig.update_traces(fill='toself', line_color=color)
fig.update_traces(mode="markers+lines")
return fig
我画了这样一幅图:
不,我想为我的雷达图添加样式,并为我的主要人物添加一些低透明度形状,以便使背景看起来像这样:
请注意,与足球相关的形状应保留在背景中,红色区域将位于这些形状之上
有人能给我指出正确的方向,告诉我如何画出这些形状,并获得与上图相似的结果吗
也许有更好的方法,但这是我的发现
使极轴栅格透明
fig.update_polars
调用添加bgcolor="rgba(0, 0, 0, 0)"
参数,使网格的背景色透明。(最后一个零很重要,其他值无关紧要)将图像添加到背景
https://plotly.com/python/images/
xref='paper'
和yref='paper'
使图像相对于纸张定位。如果xref='x'
和yref='y'
,则使用笛卡尔坐标轴定位图像。我没有找到相对于极坐标定位图像的可能性李>x=0.5, y=0.5, xanchor='center', yanchor='middle'
使图像居中李>sizing="contain"
保持图像大小不变。其他可能的值为“包含”和“拉伸”李>source
可以是URL字符串或PIL.Image
实例李>得出的数字
注释
<g class=layer-below>
内的DOM中,这与极坐标图(<g class=polarlayer>
)中的<g>
-元素不同,它们有一个公共父<svg class=main-svg>
,该父<div class=svg-container>
李>额外资源
相关问题 更多 >
编程相关推荐