Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly Python - Change font of table

Tags:

python

plotly

I have a table that I produced in plotly, and I want to change the font to 'Gill Sans'.

I am having trouble making it change. Is this possible?

This is my code:

groupA = new_df.groupby('Call').agg({'TotalGrantValue':sum, 'FirstReceivedDate':'count'}).rename(columns={'FirstReceivedDate':'Count'})
groupA['TotalGrantValue'] = groupA['TotalGrantValue'].map('{:,.2f}'.format)

colorscale = [[0, '#7f7f7f'],[.5, '#F1EDED'],[1, '#ffffff']]

table = ff.create_table(groupA, index=True,colorscale=colorscale, height_constant=14, index_title='Date')
table.layout.width = 700
for i in range(len(table.layout.annotations)):
    table.layout.annotations[i].font.size = 10
plotly.offline.iplot(table, config={"displayModeBar": False}, show_link=False, filename='index_table_pd')
like image 947
ScoutEU Avatar asked Apr 16 '26 17:04

ScoutEU


1 Answers

You need to define a layout parameter as stated in https://plot.ly/python/axes/.

from the same page, there is an example code that should help you:

layout = go.Layout(
    xaxis=dict(
        title='AXIS TITLE',
        titlefont=dict(
            family='Arial, sans-serif',
            size=18,
            color='lightgrey'
        ),
        showticklabels=True,
        tickangle=45,
        tickfont=dict(
            family='Old Standard TT, serif',
            size=14,
            color='black'
        ),
        exponentformat='e',
        showexponent='All'
    ),
    yaxis=dict(
        title='AXIS TITLE',
        titlefont=dict(
            family='Arial, sans-serif',
            size=18,
            color='lightgrey'
        ),
        showticklabels=True,
        tickangle=45,
        tickfont=dict(
            family='Old Standard TT, serif',
            size=14,
            color='black'
        ),
        exponentformat='e',
        showexponent='All'
    )
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='axes-labels')
like image 162
FedRo Avatar answered Apr 18 '26 09:04

FedRo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!