2
votes

I am trying to change the figure size (height and width) of the figure that I called using plotly cufflinks for pandas. I know that I could separately Layout from plotly.graph_objs and then give the height and width command. However, is there a way I could control the font and/or figure parameters using cufflinks.

I am plotting the Reasons for delisting of stocks on X axis and their count on Y.

Here is my code

grped = d_list_data.groupby(['Reasons Short']).size()
import cufflinks as cf
grped.iplot(kind = 'bar', 
        xTitle = 'Reasons for Delisting', 
        yTitle= 'Count', 
        title= 'Delisting Reasons since 2001', 
        theme = 'polar',
        )
2

2 Answers

3
votes

Define a Layout with your desired height and width properties and use it inside the cufflinks iplot call.

layout1 = cf.Layout(
    height=300,
    width=200
)
grped.iplot(kind = 'bar', 
        xTitle = 'Reasons for Delisting', 
        yTitle= 'Count', 
        title= 'Delisting Reasons since 2001', 
        theme = 'polar',
        layout=layout1
        )
2
votes

I tried this within Jupyterlab and using the above approach was getting error: AttributeError: 'Layout' object has no attribute 'get'

Converting the layout to a dict as suggested here (https://community.plot.ly/t/cant-edit-layouts-with-cufflinks/15038/4) made it work.

So, the above becomes:

layout1 = cf.Layout(
    height=300,
    width=200
)
grped.iplot(kind = 'bar', 
        xTitle = 'Reasons for Delisting', 
        yTitle= 'Count', 
        title= 'Delisting Reasons since 2001', 
        theme = 'polar',
        layout=layout1.to_plotly_json()
        )