2

I am doing a Bubble chart with python using plotly. I want to visualize word frequencies. So I have made two columns with 5 bubbles and I would like to write the word inside each bubble. My code is:

trace0 = go.Scatter(
x=[1, 1, 1, 1, 1],
y=[1, 2, 3, 4, 5],
mode='markers',
text=['plant', 'use', 'student', 'show', 'water'],  #words I want to show
textposition='top center',
marker=dict(
    size=norm,
color=['rgb(255, 144, 14)','rgb(255, 144, 14)','rgb(255, 144, 14)', 'rgb(255, 144, 14)',
           'rgb(255, 144, 14)'],

)

)

trace1 = go.Scatter(
x=[2, 2, 2, 2, 2],
y=[1, 2, 3, 4, 5],
mode='markers',
text=['use', 'water', 'diagram', 'show', 'plant'],   #words I want to show
textposition='top center',
marker=dict(
    size=norm,
color=['rgb(93, 164, 214)','rgb(93, 164, 214)','rgb(93, 164, 214)','rgb(93, 164, 214)','rgb(93, 164, 214)'],

)
)

data = [trace0,trace1]
py.iplot(data, filename='bubblechart-size', layout=layout)

The problem is that no word is showed here. How to change the code to visualize them?

Thank you,

1 Answer 1

6

I toook the example from this website Text and Annotations in Plotly

I believe your 'mode' parameter is not accurate.

trace2 = go.Scatter(
                   x=[0, 1, 2],
                   y=[2, 2, 2],
                   mode='markers+text',
                   name='Markers and Text',
                   text=['Text D', 'Text E', 'Text F'],
                   textposition='bottom center'
                   )

So you should write in the mode parameter: mode='markers+text'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.