在小提琴图表 PlotlyJS 中突出显示一点

To highlight one point in Violin chart PlotlyJS

我正在使用 PlotylyJS 库的 Violin 图表,它需要一个元素数组并将其绘制在图表上。如果我想用与该数组不同的颜色突出显示一个点,可以吗?

就像我的数组是

demoViolin = [31.8, 63.5, 65, 59, 71, 72, 79, 68, 66, 89, 71, 67, 77]

我想在图表上绘制它,但我希望点 65 用不同的颜色突出显示。

我希望这能成为您问题的见解。

您可以使用 selectedpointsselected 来突出显示。

var data = [{  
    //https://plotly.com/javascript/reference/violin/#violin-selectedpoints
    selectedpoints: [2],
    selected : {
        marker :{
            color: 'rgb(255,0,0)'
        }
    },
    //jitter: 0, //If needed points align same x-axis
    type: 'violin',
    y: demoViolin, 
    points: 'all',  
    box: {
        visible: true
    },
    boxpoints: true,
    ...
}

这里是Demo

此外,请提醒箱线图支持异常值特征(参见Here)。