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,
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'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.