看下面的代码,我搞砸了字体、内部/外部和其他格式选项,但没有任何运气。我什至不确定这些奇怪的涂鸦是什么
import plotly.graph_objs as go
import pandas as pd
marketing_funnel_count = marketing_funnel_count.sort_values('FUNNEL_EVENT_COUNT', ascending=False)
# Calculate the percent change by level
marketing_funnel_count['Percent Change'] = [100.0] + [(marketing_funnel_count['FUNNEL_EVENT_COUNT'][i] / marketing_funnel_count['FUNNEL_EVENT_COUNT'][i-1]) * 100 for i in range(1, len(marketing_funnel_count))]
# Create the funnel chart
fig = go.Figure(go.Funnel(
y=marketing_funnel_count['FUNNEL_EVENT'],
x=marketing_funnel_count['FUNNEL_EVENT_COUNT'],
textposition='inside',
textinfo='percent previous',
marker=dict(color=['#FFD700', '#C0C0C0', '#CD7F32', '#800000', '#FFD700', '#C0C0C0']),
connector=dict(line_color='rgba(0,0,0,0)', line_width=0.1),
connector_visible=False,
showlegend=False))
# Add the percent change annotations
for i in range(len(marketing_funnel_count)):
fig.add_annotation(x=marketing_funnel_count['FUNNEL_EVENT_COUNT'][i], y=marketing_funnel_count['FUNNEL_EVENT'][i],
text=f'{marketing_funnel_count["Percent Change"][i]:.1f}%',
showarrow=False)
# Show the chart
fig.show()