python - 在 Plotly 悬停文本(Python)中更改字体大小并限制文本长度
问题描述
我有一个由 9 个跟踪散点图组成的散点图,其中一个将进入 Dash Dashboard。
我只提供了第一个跟踪以使代码更短更容易,但是如果您需要查看其他 8 个,我可以提供它们(它们都与此跟踪相似)。
我需要帮助来执行以下操作:
更改悬停文本的字体大小
为悬停文本指定一个截止长度,就像它继续离开页面一样。
trace0= go.Scatter( x =df[df['Topic'] == 'Time consuming tasks']['x'], y = df[df['Topic'] == 'Time consuming tasks']['y'], mode = 'markers', text= df[df['Topic'] == 'Time consuming tasks']['challenges'], marker = dict( size = 9, line = dict( width = 2, ) ), name = 'First Plot', showlegend=True) app.layout = html.Div([dcc.Graph(id='scatterplot', figure = {'data' : [trace0, trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8], 'layout' : go.Layout(title='Biggest hindrances in your life?', xaxis = {'title':'x axis'}, yaxis = {'title': 'y axis'}, height = 550, titlefont= {'size':33}, hovermode = 'closest', legend=dict( traceorder='normal', font=dict( family='sans-serif', size=25, color='#000' ) ) ) } ) ])
多谢你们!
解决方案
我没有运行您的完整示例,但是,就我而言,以下解决了该问题:
go.Layout(title='Biggest hindrances in your life?',
#other options for the plot
hoverlabel=dict(font=dict(family='sans-serif', size=25)))
希望回答第1点。
编辑
刚刚找到这个页面,可能也有用 https://plotly.com/python/hover-text-and-formatting/
推荐阅读
- javascript - Axios.get 重复基本 URL 两次
- node.js - 处理工作线程中的异步消息
- php - 如何将 php 代码集成到 vuejs 项目中以进行生产构建?
- python-3.x - 删除巨大配合文件的列
- triggers - 重新保存文件后ZABBIX triggers显示多次
- python - 按小时和匹配搜索条件的事件数对基于文本的日志文件进行格式化和排序
- ios - 从 didFinishLaunchingWithOptions 调用时,3D Touch 快速操作不起作用
- xml - 如何替换 XSLT 中的选定字符
- laravel - 我应该在模型上放置有关身份验证的逻辑吗?
- javascript - ReactJS - 使用 onclick 切换类