【问题标题】:Change Marker Shapes in Plotly .js在 Plotly .js 中更改标记形状
【发布时间】:2018-02-06 19:49:16
【问题描述】:

我正在寻求一些帮助来更改 plotly.js 库中的标记形状。

我要做的是将每个组的第一个标记和最后一个标记更改为垂直线,将中间的标记更改为菱形。

我已经从 plotly 遵循了这个参考 link,但似乎无法让它工作。

这是我正在使用的 JS。

var subject = ["Title 1","Title 1","Title 1","Title 2","Title 2","Title 2"];
var score = [40,50,60,20,40,60];
var data = [{
    type: 'scatter',
    x: score,
    y: subject,
    mode: 'line',      
    transforms: [{
        type: 'groupby',
        groups: subject,
    }],  
    hoverinfo: 'text',
    text: ['Lower Index : 40','Est : 50','Higher Index : 60','Lower Index : 20','Est : 40','Higher Index : 60'],
    marker: {
        size: 12,
        shape: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
    },
}];
var layout = {
    xaxis: {
        type: '-',
        title: "x Title",
        range:[0,100]
    },
    yaxis: {
        title: "Y title",
    },
    title: "Main Title",
    showlegend: false,
    legend: {"orientation": "h"}
    };
Plotly.plot('myGraph', data,layout)

和同一个例子的代码笔

https://codepen.io/dsadnick/pen/xYEXXw

【问题讨论】:

    标签: javascript plotly


    【解决方案1】:

    一行一行我发现了问题,

    marker: {
        size: 12,
        shape: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
    },
    

    应该是

    marker: {
        size: 12,
        symbol: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
    },
    

    【讨论】:

      猜你喜欢
      • 2018-10-07
      • 2020-08-16
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-25
      • 2017-02-03
      • 2017-12-18
      相关资源
      最近更新 更多