我有以下Pandas 数据框
import pandas as pd
foo = pd.DataFrame({'country': {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e'},
'unweighted': {0: 18.0, 1: 16.9, 2: 13.3, 3: 11.3, 4: 13.1},
'weighted_1': {0: 17.7, 1: 15.8, 2: 14.0, 3: 11.2, 4: 12.8},
'weighted_2': {0: 17.8, 1: 15.8, 2: 14.0, 3: 11.2, 4: 12.8}})
country unweighted weighted_1 weighted_2
0 a 18.0 17.7 17.8
1 b 16.9 15.8 15.8
2 c 13.3 14.0 14.0
3 d 11.3 11.2 11.2
4 e 13.1 12.8 12.8
我正在使用以下代码生成条形图,该条形图使用plotly_express
import plotly.express as px
px.bar(
so,
x='country',
y=['unweighted', 'weighted_1', 'weighted_2'],
barmode='group',
)
我还想在每个wine 吧展示text
美元.
我试过了
px.bar(
so,
x='country',
y=['unweighted', 'weighted_1', 'weighted_2'],
text=['unweighted', 'weighted_1', 'weighted_2'],
barmode='group',
)
但它不起作用.
我怎么能这么做呢?