Plotly express inconsistent behavior with text size

50 views Asked by At

I am having trouble controlling text size within plotly.express figures.

If I create some fake data like so, it appears to work.

df = pd.DataFrame({
    "x":['1','2','2','1','1','2','2','1'], 
    'y':[10,20,30,40,30,20,10,10],
    'type':['a','a','b','b','a','a','b','b'], 
    'text':['00000','000','0','00','00000','000','0','00']})

fig = px.bar(df, x='x',y='y', text='text', barmode="group", color='type')
fig.update_traces(textposition='outside', textfont_size=3000000, textangle=90, cliponaxis=False)
fig.show()

enter image description here

Note that I'm setting the textfont_size ridiculously large, but we can see this actually reflected in the figure.

The problem

However, when I use my real data. The text size is simply small, despite the very large textfont_size. I can not share my real data here, but the dtypes are identical to the example shown above.

# my real data
data = ...  # can't share

assert all(data.dtypes == df.dtypes) # not a problem, all identical

print(data.dtypes)
x       object
y        int64
type    object
text    object
dtype: object

# identical code as above
fig = px.bar(data, x='x',y='y', text='text', barmode="group", color='type')
fig.update_traces(textposition='outside', textfont_size=3000000, textangle=90, cliponaxis=False)
fig.show()

As we can see, while everything appears (?) identical, the large textfont_size is ignored and instead the text is small.

enter image description here

0

There are 0 answers