✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

How to add conditional text position on scatter graph

We are trying to achieve following using Plotly.js
image

But based on documentation here, textposition can only be specified at trace level. Is there a way to achieve the above?
Basically text for negative numbers should come below and text for positive numbers should be above.

Sample Code:


var trace2 = {
  x: [-10, -5, -1, 1, 5, 10],
  y: [1.3, 0.6, 0.1, -0.1, -0.6, -3.1],
  mode: 'markers+text',
  type: 'scatter',
  name: 'Team B',
  text: ['B-a', 'B-b', 'B-c', 'B-d', 'B-e', 'B-f'],
  textfont : {
    family:'Times New Roman'
  },
  textposition: 'bottom center',
  marker: { size: 12 }
};

var data = [ trace2 ];

var layout = {
  xaxis: {
    range: [ -15, 15 ]
  },
  yaxis: {
    range: [-4, 2]
  },
  legend: {
    y: 0.5,
    yref: 'paper',
    font: {
      family: 'Arial, sans-serif',
      size: 20,
      color: 'grey',
    }
  },
  title:'Data Labels on the Plot'
};

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