> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Plotly または Bokeh のチャートを Tables に追加するにはどうすればよいですか？

Plotly または Bokeh の図を表に直接組み込むことはサポートされていません。代わりに、図を HTML にエクスポートし、その HTML を表に含めます。以下のサンプルでは、インタラクティブな Plotly および Bokeh のチャートでこれを行う方法を示します。

<Tabs>
  <Tab title="Plotly">
    ```python theme={"system"}
    import wandb
    import plotly.express as px

    # 新しい run を初期化します
    with wandb.init(project="log-plotly-fig-tables", name="plotly_html") as run:

        # 表を作成します
        table = wandb.Table(columns=["plotly_figure"])

        # Plotly の図のパスを定義します
        path_to_plotly_html = "./plotly_figure.html"

        # Plotly の図を作成します
        fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

        # Plotly の図を HTML にエクスポートします
        # auto_play を False に設定すると、アニメーション付きの Plotly チャートの自動再生を防げます
        fig.write_html(path_to_plotly_html, auto_play=False)

        # Plotly の図を HTML ファイルとして表に追加します
        table.add_data(wandb.Html(path_to_plotly_html))

        # 表をログします
        run.log({"test_table": table})

    ```
  </Tab>

  <Tab title="Bokeh">
    ```python theme={"system"}
    from scipy.signal import spectrogram
    import holoviews as hv
    import panel as pn
    from scipy.io import wavfile
    import numpy as np
    from bokeh.resources import INLINE

    hv.extension("bokeh", logo=False)
    import wandb

    def save_audio_with_bokeh_plot_to_html(audio_path, html_file_name):
        sr, wav_data = wavfile.read(audio_path)
        duration = len(wav_data) / sr
        f, t, sxx = spectrogram(wav_data, sr)
        spec_gram = hv.Image((t, f, np.log10(sxx)), ["Time (s)", "Frequency (Hz)"]).opts(
            width=500, height=150, labelled=[]
        )
        audio = pn.pane.Audio(wav_data, sample_rate=sr, name="Audio", throttle=500)
        slider = pn.widgets.FloatSlider(end=duration, visible=False)
        line = hv.VLine(0).opts(color="white")
        slider.jslink(audio, value="time", bidirectional=True)
        slider.jslink(line, value="glyph.location")
        combined = pn.Row(audio, spec_gram * line, slider).save(html_file_name)

    html_file_name = "audio_with_plot.html"
    audio_path = "hello.wav"
    save_audio_with_bokeh_plot_to_html(audio_path, html_file_name)

    wandb_html = wandb.Html(html_file_name)
    with wandb.init(project="audio_test") as run:
        my_table = wandb.Table(columns=["audio_with_plot"], data=[[wandb_html], [wandb_html]])
        run.log({"audio_table": my_table})
    ```
  </Tab>
</Tabs>

***

<Badge stroke shape="pill" color="blue" size="md">[Experiments](/ja/support/models/tags/experiments)</Badge><Badge stroke shape="pill" color="blue" size="md">[Tables](/ja/support/models/tags/tables)</Badge><Badge stroke shape="pill" color="blue" size="md">[チャート](/ja/support/models/tags/charts)</Badge>
