2017-07-14 7 views
0

Plotlyで散布図を使用するとき、x軸の値が同じマーカーが2つ以上ある場合、ホバーテキストを取得できません。plotly x軸ホバーテキストの問題

誰でもこの問題を解決できますか?

これは怪しいですか?

行に最も近いマーカーを確認します。

コードは、ここであなたは、おそらくあなたのケースでclosestに設定する必要がありhovermodeを探しているhttps://jsfiddle.net/qjdt92h2/

var trace1 = { 
    x: [13.5, 12, 13, 14,13], 
    y: [15, 17, 13.6, 17,18], 
    text: ['4.17 below the mean', '4.17 below the mean', '0.17 below the mean', '0.17 below the mean', '0.83 above the mean', '7.83 above the mean'], 
    mode: 'markers', 
    name: 'Grade/Mean grade', 
    marker:{ 
    color: 'rgb(255, 99, 132)' 
    } 


}; 

var trace2 = { 
    x: [0, 20], 
    y: [0, 20], 
    mode: 'lines', 
    name: 'Guide line', 
    marker:{ 
    color: '#023587' 
    } 
}; 


var data = [ trace1, trace2]; 

var layout = { 
    title:'Line and Scatter Plot' 
}; 

Plotly.newPlot('myDiv', data, layout); 

答えて

1

です。

var trace1 = { 
 
    x: [13.5, 12, 13, 14, 13], 
 
    y: [15, 17, 13.6, 17, 18], 
 
    text: ['4.17 below the mean', '4.17 below the mean', '0.17 below the mean', '0.17 below the mean', '0.83 above the mean', '7.83 above the mean'], 
 
    mode: 'markers', 
 
    name: 'Grade/Mean grade', 
 
    marker: {color: 'rgb(255, 99, 132)'} 
 
}; 
 

 
var trace2 = { 
 
    x: [0, 20], 
 
    y: [0, 20], 
 
    mode: 'lines', 
 
    name: 'Guide line', 
 
    marker:{color: '#023587'} 
 
}; 
 

 

 
var data = [trace1, trace2]; 
 
var layout = { 
 
    title:'Line and Scatter Plot', 
 
    hovermode: 'closest' 
 
}; 
 

 
Plotly.newPlot('myDiv', data, layout);
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> 
 
<div id="myDiv"></div>

+0

ありがとうございました。それはまさに私が探していたものです。 – Ankit