下面的代码生成一个饼图,显示在图片中。我需要在饼图中的价格后面加一个$符号,有人能帮我吗?我只是开始有计划地探索:)提前谢谢你
pie = data[["room_type","price"]]
pie_chart = pie.groupby(['room_type'], as_index=False).median()
fig3 = px.pie(pie_chart,
values='price',
names='room_type',
color_discrete_sequence =['#de425b','#ef805b','#f7b672'])
fig3.update_traces(hoverinfo='label+percent', textinfo='value', textfont_size=17)
fig3.update_layout(
title_text = 'Median of prices per room type',
legend_title = 'Room type',
title_font = dict(family='Courier', size=16, color='black'),
title_x=0.5,
font_family="Courier",
font_color="black",
legend_title_font_color="black"
)
在
fig.update_traces method
中,您可以传递textinfo='text'
而不是textinfo='labels'
,然后将文本定义为数据帧中的价格列表,每个价格的前缀为美元符号相关问题 更多 >
编程相关推荐