Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to do scatter plot with text boxes

HI Any one has any idea how to make a plot like this?

I can’t find a single example that looks like this.

Quite close:

data = go.Scatter(x=[1, 2, 3],
                  y=[12, 14, 9],
                  marker={'symbol': 'square', 'size': 80},
                  text=['Campaign A', 'Campaign B' + '<br>' + 'Second Line', 'Campaign C'])

Keep in mind:

  • mode: has to be ‘markers+text’
  • marker: was chosen as ‘square’ which is the closest shape available to the rectangle. The full list of symbols can be found here:
  • In cases where the text is too long and doesn’t fit on top of the square, you can split the text with <br>, because this is basically HTML, and accepts some other tags, like <b> for example.