Im trying to plot the different stats of two football players mirrored across. Id like the better stat to have a green color and the worse stat red. Only problem is In my color scale one color will be red and one will be green which merges both. Does anyone know a solution or a better way to plot this kind of graph?
data =[['Messi', 88]]
data2 = [['Ronaldo', -88]]
df = pd.DataFrame(data, columns=['Player', 'Dribbling'])
df2 = pd.DataFrame(data2, columns=['Player', 'Dribbling'])
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(go.Bar(
orientation='h',
name=df['Player'],
x=df['Dribbling'],
marker_color=((df.Dribbling >= df2.Dribbling)).astype('int'),
marker_colorscale=[[0, 'red'], [1, 'green']],
),secondary_y=False)
fig.add_trace(go.Bar(
orientation='h',
name=df2['Player'],
x=df2['Dribbling'],
marker_color=((df.Dribbling >= df2.Dribbling)).astype('int'),
marker_colorscale=[[0, 'red'], [1, 'green']],
),secondary_y=True)
fig.update_layout(
barmode="group"
)
fig.update_xaxes(range=[-100, 100])

