以绘图方式自定义悬停框:Python以适应文本

以绘图方式自定义悬停框:Python以适应文本,python,hover,plotly,Python,Hover,Plotly,有没有办法在plotly中自定义悬停文本框?我必须在悬停框中显示的文本很长,不适合在屏幕上显示。是否有办法更改悬停文本框的尺寸或使文本变小以使其完全适合屏幕。 更好的办法是在图表的一侧有一个固定的框,当我滚动数据点时,它会显示相应的注释,但我不知道如何做到这一点 下面是我试图用一些类似长度的文本所做的示例 import plotly.plotly as py from plotly.graph_objs import * import plotly import matplotlib.pyplo

有没有办法在plotly中自定义悬停文本框?我必须在悬停框中显示的文本很长,不适合在屏幕上显示。是否有办法更改悬停文本框的尺寸或使文本变小以使其完全适合屏幕。 更好的办法是在图表的一侧有一个固定的框,当我滚动数据点时,它会显示相应的注释,但我不知道如何做到这一点

下面是我试图用一些类似长度的文本所做的示例

import plotly.plotly as py
from plotly.graph_objs import *
import plotly
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd


notes=["Clinton is also navigating delicate ties with Israel and the American Jewish community, an influential group of voters and donors. Israeli Prime Minister Benjamin Netanyahu, a fierce critic of the Obama administration's outreach to Iran, described the framework deal as a threat to the very survival of his nation.", "Fire crews in Cambria County were called to the Revloc duplex Friday morning and found much of the building engulfed in flames. Chief Deputy Coroner Jeffrey Leeds said at least seven people were in the duplex and all, but one, were able to get out safely.Witnesses said Jake Lewis, 24, re-entered the house to rescue 65-year-old Anna LaJudice. But father, Robert LaJudice, told The (Altoona) Mirror.Their bodies were later recovered. The deputy coroner said autopsies determined that both died from smoke and gas inhalation.", "As crews worked to tear down the rest of the home, Ott said she planned to attend a church service and say a prayer for the family."]
balance=[1000,2000,4000]
dates=[1,2,3]


data1 = Data([
    Scatter(
        x=dates,
        y=balance,
        mode='markers',
        text=notes,        
    )
])
layout = Layout(
    title='Hover over the points to see the text',autosize=True,   
)
fig = Figure(data=data1, layout=layout,)

fig['layout'].update(
    hovermode='closest',  
    showlegend=False,     
    autosize=True,       

)
plot_url = py.plot(fig, filename='hover-chart-basic')
py.plot(fig, filename='hover-chart-basic')

任何帮助都将不胜感激

您可能希望查看注释以创建固定文本框。在这里查看我们的文档:您将看到如何为批注或悬停文本指定字体大小。

秘诀是在悬停字符串文本中每隔约90个字符插入一个html
标记。您可以使用下面的正则表达式来匹配每90行

(.{1,90})(\\s|$)