在Plotly .js中更改标记形状 [英] Change Marker Shapes in Plotly .js
本文介绍了在Plotly .js中更改标记形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一点帮助来更改plotly.js库中的标记形状.
Im looking for a little assistance in changing the marker shapes in the plotly.js libary.
我想要做的是将每个组的第一个标记和最后一个标记更改为垂直线,将中间的标记更改为菱形.
What I am looking to do is change the first Marker and last marker for each group to a vertical line, and the middle one to a diamond.
我已经从阴暗地跟随了这个参考文献链接,但似乎无法使其正常工作.
I have followed this reference link from plotly but can not seem to get it to work.
这是我正在使用的JS.
Here is my JS that im using.
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
推荐答案
一行又一行地找出问题所在,
After going line by line i figured out the problem,
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"]
},
这篇关于在Plotly .js中更改标记形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文