如何在PLOTLY JS中为每个子图添加标题

art*_*ist 2 javascript graph title plotly.js

就像在主题上一样。我从阴暗地阅读文档,但没有找到任何有用的信息。也许有人知道如何在PLOTLY JS中为每个图添加标题?

Md *_*ush 5

目前,您无法直接设置子图标题。但是您可以使用设置子图标题annotation text

听到就是一个例子

    //Set annotations text in layout configuration
annotations: [{
        text: "First subplot",
          font: {
          size: 16,
           color: 'green',
        },
        showarrow: false,
        align: 'center',
        x: 0.13, //position in x domain
        y: 1, //position in y domain
        xref: 'paper',
        yref: 'paper',
      },
        {
          text: "Second subplot",
          font: {
          size: 16,
          color: 'orange',
        },
        showarrow: false,
        align: 'center',
        x: 0.9, //position in x domain
        y: 1,  // position in y domain
        xref: 'paper',
        yref: 'paper',
        }
      ]
Run Code Online (Sandbox Code Playgroud)

注释文本plotly.js