How to see the plot made in python using pandas and matplotlib -
i following tutorial http://ahmedbesbes.com/how-to-score-08134-in-titanic-kaggle-challenge.html , following code
from ipython.core.display import html html(""" <style> .output_png { display: table-cell; text-align: center; vertical-align: middle; } </style> """) # remove warnings import warnings warnings.filterwarnings('ignore') # --- import pandas pd pd.options.display.max_columns = 100 import matplotlib matplotlib.use('tkagg') import matplotlib.pyplot plt matplotlib.style.use('ggplot') import numpy np pd.options.display.max_rows = 100 data = pd.read_csv('./data/train.csv') data.head() data['age'].fillna(data['age'].median(), inplace=true) survived_sex = data[data['survived']==1]['sex'].value_counts() dead_sex = data[data['survived']==0]['sex'].value_counts() df = pd.dataframe([survived_sex,dead_sex]) df.index = ['survived','dead'] df.plot(kind='bar',stacked=true, figsize=(15,8))
i dont see plot. how see plot?
try using plt.show()
@ end.
edit:
also, may need add %matplotlib inline
explained here: how make ipython notebook matplotlib plot inline
Comments
Post a Comment