user3287712
user3287712

Reputation: 57

How to plot on Pandas Python

I have a data frame called that looks like this. It is called p1plot1:

         0
0   139245
1   125395
2   116835
3    85170
4    58075
5    40050

I want to create a bar plot with the integers on the x axis and the values on the y axis. I tried using:

p1plot1.plot(kind='bar')

And got the output:

<matplotlib.axes.AxesSubplot object at 0x1fec7ca10>

How do I get an actual image file with the plot? Was I supposed to import something?

Upvotes: 0

Views: 382

Answers (3)

cwharland
cwharland

Reputation: 6713

Launch Ipython notebook with

--pylab=inline

Then all of your plots will be shown inline

Upvotes: 0

cphlewis
cphlewis

Reputation: 16269

Finish up with

show()

to display.

Upvotes: 1

waitingkuo
waitingkuo

Reputation: 93964

In the non-interactive mode, you need to use show to display the image

import matplotlib.pyplot as plt

# plt.plot something

plt.show()

If you want to display the figure as you plot it, turn it into interactive mode

import matplotlib.pyplot as plt

plt.ion()

# plt.plot something

Upvotes: 4

Related Questions