9

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')

どんな助けでも大歓迎です!

4

2 に答える 2

0

注釈を調べて、固定テキスト ボックスを作成することをお勧めします。こちらのドキュメントをご覧ください: https://plot.ly/python/text-and-annotations/注釈またはホバー テキストのフォント サイズを指定する方法を確認できます。

于 2015-04-06T20:06:44.543 に答える
-1

その秘訣は、ホバー文字列テキストに約 90 文字ごとに html <br> タグを挿入することです。以下の正規表現を使用して、約 90 行ごとに一致させることができます。

(.{1,90})(\\s|$)
于 2016-06-20T20:44:01.173 に答える