bidby
bidby

Reputation: 738

Matplotlib notebook magic inline/plotting commands not working

I am running a jupyter notebook (5.7.0) with pandas (0.23.4) and matplotlib (3.0.1). When I try to plot using the

pandas.DataFrame.plot()

function it gives me the text of the object:

<pandas.plotting._core.FramePlotMethods object at 0x7f612fdb74a8>

Naturally I googled this, and have sinced tried the magic commands:

%matplotlib inline

and

%matplotlib notebook

in the very first cell after shutting down the notebook and restarting it, and still it seems to make no difference.

So for completeness sake, my first cell is the magic command, and in the second I import numpy,pandas and matplotlib. In the following cells are create my array and pass it to the DataFrame command. Finally I call:

pandas.DataFrame.plot(df) 

and the text of the object (from above) appears, regardless of whether I run the magic commands or not. Have I got the incorrect version of something? Do I need to restart the entire notebook server?

Upvotes: 0

Views: 356

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339580

You misunderstood the way plotting works. What you are trying here is

import pandas
df=pandas.DataFrame([1,2,3])
pandas.DataFrame.plot(df)

What you need to do instead is

import pandas
df=pandas.DataFrame([1,2,3])
df.plot()

Upvotes: 1

Related Questions