I have a problem, to change the color of a single circle in my plotly graph. I want to color the third ring white and make it fat and also the 7th ring, to show separate layers.
I have tried a lot, like line_color and so on, but it did not affect the ring itself, but the piece of the cake.
I will give you an example code, where I need this to be implemented:
import plotly.graph_objects as go
import matplotlib.cm as cm
import matplotlib.colors as mcolors
# Daten für das Beispiel (Mittelwerte aus der eingangs erwähnten Tabelle)
dimensionen = [
'Daten/Technologie', 'Organisation und Prozesse', 'Strategie und Governance',
'Mindset und Kultur', 'Umsetzbarkeit und Zusammenarbeit', 'Externe Marktteilnehmer'
]
# Mittelwerte der Skalen pro Dimension (aus der Tabelle)
mittelwerte = {
'Daten/Technologie': 6, 'Organisation und Prozesse': 5, 'Strategie und Governance': 7,
'Mindset und Kultur': 8, 'Umsetzbarkeit und Zusammenarbeit': 3, 'Externe Marktteilnehmer': 2
}
# Viridis colormap für die Farbauswahl
viridis = cm.get_cmap('viridis', 12)
colors = [mcolors.to_hex(viridis(i)) for i in range(viridis.N)]
# Funktion zur Erstellung des erweiterten Donut-Radars
def create_extended_donut_radar(dimensionen, mittelwerte):
num_dimensionen = len(dimensionen)
num_scales = 11 # 11 Skalen von 0 bis 10
fig = go.Figure()
for idx, dim_name in enumerate(dimensionen):
mittelwert = mittelwerte[dim_name]
# Bar für jede Skala hinzufügen
for scale in range(num_scales):
inner_radius = scale * 0.09 + 0.05 # Adjusted for equal spacing
outer_radius = inner_radius + 0.09 # Adjusted for equal spacing
if scale == 0:
color = 'white'
elif scale <= mittelwert:
color = colors[scale]
else:
color = 'lightgrey'
fig.add_trace(go.Barpolar(
r=[inner_radius, outer_radius],
theta=[(360 / num_dimensionen) * idx] ,
width=[(360 / num_dimensionen) - 1],
marker_color=color,
marker_line_color='black',
marker_line_width=2,
opacity=0.7
))
# Layout anpassen
fig.update_layout(
title='',
title_font_size=24,
title_x=0.5,
polar=dict(
radialaxis=dict(visible=False),
angularaxis=dict(visible=False)
),
showlegend=False
)
# Plotly Diagramm im Standard-Browser anzeigen
fig.show(renderer='browser')
# Donut-Radar erstellen
create_extended_donut_radar(dimensionen, mittelwerte)