HERE is ONE EXAMPLE. actually even though you normalizing numbers , when you change the window size ,they will overlap . because scatter method is not to fill the area . the smaller the window size ,the nearer the texts are.
Besides, hoverinfo is not accurate , because the xaxis of each text are so near. I find that the hoverinfo is based on differeces of the value of xaxis , but not the text itself. When you hover on one text, the info may be another one’s, because their xaxis value is similar and near .
My english is poor , may i make you understand me?
import pandas as pd
import plotly as py
import plotly.graph_objs as go
import random
words = [‘征信’, ‘拍拍贷’, ‘查询’, ‘报告’, ‘贷款’, ‘个人’, ‘怎么’, ‘信用卡’, ‘逾期’, ‘被拒’, ‘如何’, ‘中心’, ‘信用’, ‘网贷’, ‘人人’, ‘分期’, ‘注册’, ‘好信’, ‘手机’, ‘钱包’, ‘个人信用’, ‘借呗’, ‘平安’, ‘捷信’, ‘微粒贷’, ‘借钱’, ‘记录’, ‘用钱’, ‘可以’, ‘花呗’, ‘身份证’, ‘拍拍’, ‘现金’, ‘微信’, ‘还款’, ‘问问’, ‘产品’, ‘51’, ‘信而富’, ‘什么’, ‘黑名单’, ‘360’, ‘17’, ‘黑户’, ‘怎么办’, ‘金融’, ‘帮你贷’, ‘消除’, ‘密码’, ‘账号’, ‘怎样’, ‘分期乐’, ‘拒绝’, ‘申请’]
frequency = [1083, 393, 353, 167, 123, 119, 83, 64, 57, 46, 44, 40, 37, 31, 29, 29, 28, 26, 25, 23, 23, 22, 21, 19, 18, 18, 18, 18, 18, 17, 15, 15, 15, 15, 14, 14, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10]
percent = [0.362086258776329, 0.13139418254764293, 0.11802072885322636, 0.055834169174189235, 0.041123370110330994, 0.03978602474088933, 0.02774991641591441, 0.02139752591106653, 0.01905717151454363, 0.015379471748579069, 0.01471079906385824, 0.013373453694416584, 0.012370444667335341, 0.010364426613172852, 0.009695753928452023, 0.009695753928452023, 0.009361417586091608, 0.008692744901370779, 0.008358408559010365, 0.0076897358742895345, 0.0076897358742895345, 0.00735539953192912, 0.007021063189568706, 0.006352390504847877, 0.006018054162487462, 0.006018054162487462, 0.006018054162487462, 0.006018054162487462, 0.006018054162487462, 0.0056837178201270475, 0.005015045135406218, 0.005015045135406218, 0.005015045135406218, 0.005015045135406218, 0.004680708793045804, 0.004680708793045804, 0.0043463724506853894, 0.0043463724506853894, 0.0043463724506853894, 0.0043463724506853894, 0.0043463724506853894, 0.0043463724506853894, 0.004012036108324975, 0.004012036108324975, 0.00367769976596456, 0.00367769976596456, 0.00367769976596456, 0.00367769976596456, 0.003343363423604146, 0.003343363423604146, 0.003343363423604146, 0.003343363423604146, 0.003343363423604146, 0.003343363423604146]
lenth = len(words)
colors = [py.colors.DEFAULT_PLOTLY_COLORS[random.randrange(1, 10)] for i in range(lenth)]
data = go.Scatter(
x=random.choices(range(lenth), k=lenth),
y=random.choices(range(lenth), k=lenth),
mode=‘text’,
text=words,
hovertext=[’{0}
{1}{2}’.format(w, f, format(p, ‘.2%’)) for w, f, p in zip(words, frequency, percent)],
hoverinfo=‘text’,
textfont={‘size’: frequency, ‘color’: colors})
layout = go.Layout({‘xaxis’: {‘showgrid’: False, ‘showticklabels’: False, ‘zeroline’: False},
‘yaxis’: {‘showgrid’: False, ‘showticklabels’: False, ‘zeroline’: False}})
fig = go.Figure(data=[data], layout=layout)
py.offline.plot(fig)