How to do scatter plot with text boxes


#1

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

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


#2

Quite close:

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

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: https://plot.ly/python/reference/#scatter-marker-symbol.
  • 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.