x2016 = data[data.year == 2016].iloc[:20,:]
num_students_size = [float(each.replace(',', '.')) for each in x2016.num_students]
international_color = [float(each) for each in x2016.international]
trace1 = go.Scatter(
x = x2016.world_rank,
y = x2016.teaching,
mode = "markers",
marker=dict(
color = international_color,
size = num_students_size,
showscale = True
),
text = x2016.university_name
)
data5 = [trace1]
iplot(data5)
这给出气泡图,并且不显示标签。如何添加标签,请帮忙] 1
答案 0 :(得分:0)
您的[data5]
更适合作为go.Figure()
对象。
下面有一个很好的顺序:https://plotly.com/python/line-and-scatter/#bubble-scatter-plots
以下是图形标签的引用: https://plotly.com/python/figure-labels/
fig.update_layout(
title="Plot Title",
xaxis_title="x Axis Title",
yaxis_title="y Axis Title",
font=dict(
family="Courier New, monospace",
size=18,
color="#7f7f7f"
)
)
fig.show()
此处的其他相关帮助和教程: https://plotly.com/python/line-and-scatter/
所以-为了在此处给出一般性提示,应执行以下操作:
data5 = go.Figure(data=trace1,
title="Plot Title",
xaxis_title="x Axis Title",
yaxis_title="y Axis Title"
)
iplot(data5)