I have a plotly histogram where I am trying to add the count on the every bar, text_auto=True
should work, but it keeps giving a error that TypeError: histogram() got an unexpected keyword argument 'text_auto'
. I checked in the official docs and it is present in the function.
That's my sample data:
index content
1 api-path-removed-without-deprecation 4236
2 request-parameter-removed 2024
3 request-property-removed 622
4 api-removed-without-deprecation 524
5 new-required-request-parameter 502
6 new-required-request-property 422
8 response-success-status-removed 367
9 request-parameter-became-required 351
10 response-body-type-changed 229
11 response-property-type-changed 224
12 response-property-enum-value-added 224
13 response-media-type-removed 212
14 request-parameter-type-changed 207
This is my code for the graph:
import plotly.express as px
fig = px.histogram(top_content_dropped, x="content", y="index", color_discrete_sequence=['#2E86C1'])
fig.update_xaxes(showline=True, linewidth=1, linecolor='black', mirror=True)
fig.update_yaxes(categoryorder='total ascending',showline=True, linewidth=1, linecolor='black', mirror=True)
fig.update_layout(template='ggplot2',width=1500, height=800)
fig.show()
Can anyone tell me where I am going wrong and how could I add the text?
This might be a version issue. text_auto=True
works fine on my end in:
fig = px.histogram(top_content_dropped, x="content", y="index", color_discrete_sequence=['#2E86C1'], text_auto=True)
I'm on Plotly version 5.10.0
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
df = pd.DataFrame({'index': {1: 'api-path-removed-without-deprecation',
2: 'request-parameter-removed',
3: 'request-property-removed',
4: 'api-removed-without-deprecation',
5: 'new-required-request-parameter',
6: 'new-required-request-property',
8: 'response-success-status-removed',
9: 'request-parameter-became-required',
10: 'response-body-type-changed',
11: 'response-property-type-changed',
12: 'response-property-enum-value-added',
13: 'response-media-type-removed',
14: 'request-parameter-type-changed'},
'content': {1: 4236,
2: 2024,
3: 622,
4: 524,
5: 502,
6: 422,
8: 367,
9: 351,
10: 229,
11: 224,
12: 224,
13: 212,
14: 207}})
top_content_dropped = df
fig = px.histogram(top_content_dropped, x="content", y="index", color_discrete_sequence=['#2E86C1'], text_auto=True)
fig.update_xaxes(showline=True, linewidth=1, linecolor='black', mirror=True)
fig.update_yaxes(categoryorder='total ascending',showline=True, linewidth=1, linecolor='black', mirror=True)
fig.update_layout(template='ggplot2',width=1500, height=800)
fig.show()