1

У меня есть такой датасет:

введите сюда описание изображения

Хочу сделать scatter, чтобы по y был friendsCount, а по x - followersCount, а при наведении на точку показывался screenName.

Пока у меня получилось так:

data = {
"screenName": ["LlngoMakeEmCum_", "_notmichelle", "jesseayye", "MrBrianLloyd", "sarahdorat_16", "wanderIustregui", "andhesonit", "Jas_Thxku", "KLitzau", "ThePettyHomo"], 
"followersCount": [319, 275, 120, 492, 128, 479, 1875, 582, 688, 204], 
"friendsCount": [112, 115, 107, 325, 218, 131, 111, 281, 186, 226]
}

twitterData = pd.DataFrame(data=data)
twitterData[["screenName", "followersCount", "friendsCount"]].plot.scatter(x="followersCount", y="friendsCount", backend="plotly")

введите сюда описание изображения

Как сделать так, чтобы дополнительно высвечивался screenName?

1

1 ответ 1

4

Попробуйте так:

import plotly.express as px

fig = px.scatter(df, x="followersCount", y="friendsCount", hover_data=["screenName"])
fig.show()

PS здесь можно посмотреть чуть более сложный вариант использования.

1
  • 1
    Спасибо, то, что надо!
    – Vetedde
    15 июл 2021 в 12:40

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.