Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot dataframe pandas not working

Tags:

pandas

I am using pandas to plot a graph. The following is my function

count_subset.plot(kind='barh', stacked=True)

The response I get is

<matplotlib.axes.AxesSubplot at 0x111fc4ad0>

I can't see the graph anywhere. Am I missing some library ?

like image 976
Vinay Joseph Avatar asked Jul 29 '14 05:07

Vinay Joseph


People also ask

Can you plot a pandas Dataframe?

We can plot a dataframe using the plot() method. But we need a dataframe to plot. We can create a dataframe by just passing a dictionary to the DataFrame() method of the pandas library.

Can pandas plot graph?

Pandas uses the plot() method to create diagrams. We can use Pyplot, a submodule of the Matplotlib library to visualize the diagram on the screen.

How do I plot columns in pandas?

To plot a specific column, use the selection method of the subset data tutorial in combination with the plot() method. Hence, the plot() method works on both Series and DataFrame .


1 Answers

You have to 'show' the plot using matplotlib's show:

import matplotlib.pyplot as plt
...  #plotting code
plt.show()

Another way is, if you use IPython, to activate the matplotlib magic to have it interactively (no need to call show then):

%matplotlib
like image 157
joris Avatar answered Sep 22 '22 06:09

joris