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],
                  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.

Hello, taking advantage of this post, is there any way to make a background on the text label over the line scatter plot? I also want to create a small box over it, I tested the suggestion in the past which worked, but is made a bit marker for my plot design.

Hi @jfratta, welcome to the forums!

Could you add an image which shows how you want the charts to look like? Unfortunately I don’t understand what you are trying to achieve.

image

Something like that…

Hi, by the looks of it, setting mode="markers+text+lines" should come close.