Shelley Hoover
Shelley Hoover

Reputation: 31

Seaborn Plot doesn't show up

I am creating a bar chart with seaborn, and it's not generating any sort of error, but nothing happens either.

This is the code I have:

import pandas 
import numpy
import matplotlib.pyplot as plt
import seaborn

data = pandas.read_csv('fy15crime.csv', low_memory = False)
seaborn.countplot(x="primary_type", data=data)
plt.xlabel('crime')
plt.ylabel('amount')

seaborn.plt.show()

I added "seaborn.plt.show() in an effort to have it show up, but it isn't working still.

Upvotes: 1

Views: 14944

Answers (3)

Dan Crosby
Dan Crosby

Reputation: 149

I was using PyCharm using a standard Python file and I had the best luck with the following:

  1. Move code to a Jupyter notebook (which can you do inside of PyCharm by right clicking on the project and choosing new - Jupyter Notebook)

  2. If running a chart that takes a lot of processing time it might not have been obvious before, but in Jupyter mode you can easily see when the cell has finished processing.

Upvotes: 0

Joe T. Boka
Joe T. Boka

Reputation: 6583

You should place this line somewhere in the top cell in Jupyter to enable inline plotting:

%matplotlib inline

Upvotes: 8

Leb
Leb

Reputation: 15953

It's simply plt.show() you were close. No need for seaborn

Upvotes: 4

Related Questions