dcc
dcc

Reputation: 1739

Python Pandas figsize not defined

I am new to pandas for data analysis and I just installed pandas with required dependencies (NumPy, python-dateutil, pytz, numexpr, bottleneck and matplotlib). But when I started trying the most basic code:

import pandas as pd
pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier
figsize(15, 5)

It complains NameError: name 'figsize' is not defined.

I am not sure if I still need some other dependencies. Could anyone shed some light on this?

Upvotes: 9

Views: 33189

Answers (4)

Mohammad Heydari
Mohammad Heydari

Reputation: 4290

using VarianleName.plot(figszie=(n,n) will solve the problem n,n could be numbers like 15,10 Using Plot Figure Size

Upvotes: 0

koliyat9811
koliyat9811

Reputation: 917

When I got the same problem I changed figsize() from function call to assignment figsize = (15,5)
And it worked for me.

Upvotes: 7

Guido van Steen
Guido van Steen

Reputation: 534

You might be using an earlier version of pandas. The function figsize() may have been introduced in a later version.

In version 1.13 I achieved something similar with a statement like df.plot(figsize=(15, 5))

Upvotes: 3

Padraic Cunningham
Padraic Cunningham

Reputation: 180401

Try using %pylab if %pylab inline does not work.

So it should be:

 %pylab
 import pandas as pd
 pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier
 figsize(15, 5)

The example is based on running the code in Ipython using Ipython magic command %pylab which gives you:

In [16]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib

If you are not using Ipython and the %pylab magic you will have to use something like:

from pylab import *
rcParams['figure.figsize'] = 15,5

If you have Ipython-notebook istalled you can start it with pylab inline using:

ipython notebook --pylab inline from the command line.

I would recommend using Ipython to start with.

This is a link to the Ipython commands quick reference

Upvotes: 13

Related Questions