I am using Violin chart of PlotylyJS library, and it takes an array of elements and plots it on the chart. Is possible if I want to highlight one point with a different color from that array?
Like if my array is
JavaScript
x
2
1
demoViolin = [31.8, 63.5, 65, 59, 71, 72, 79, 68, 66, 89, 71, 67, 77]
2
I want to plot this on the graph but I want the point 65 to be highlighted with a different color.
Advertisement
Answer
I hope this could be Insight of your issue.
You can use selectedpoints
with selected
for highlighting.
JavaScript
1
19
19
1
var data = [{
2
//https://plotly.com/javascript/reference/violin/#violin-selectedpoints
3
selectedpoints: [2],
4
selected : {
5
marker :{
6
color: 'rgb(255,0,0)'
7
}
8
},
9
//jitter: 0, //If needed points align same x-axis
10
type: 'violin',
11
y: demoViolin,
12
points: 'all',
13
box: {
14
visible: true
15
},
16
boxpoints: true,
17
18
}
19
Here is Demo.
Also, please remind boxplot support feature outlier(see Here).