2016-07-20 11 views
0

を示していません。ウィンドウが開き、ラベルと軸は表示されますがプロットは表示されません。私は何が間違っているのか分かりません。多分それは私がここでmatplotlibのは、私は折れ線グラフを表示するには、このコードを書かれているが、プロットが表示されないグラフ

import pandas as pd 
import numpy as np 

import matplotlib.pyplot as plt 
import seaborn as sns 

df = pd.read_csv("passing_stats_1970_2016.csv", index_col=0) 
df = df[pd.notnull(df['Season'])] 

# print(qb_data.head()) 

avg_td = df.groupby('Season').TD.mean() 


# setting up seaborn, creating white background 
sns.set_style("white") 

# setting height to 12, width to 9 
plt.figure(figsize=(12,9)) 

# getting x and y values 
x_values = df.Season.unique() 
y_values = avg_td 


# title 
title = ("Average TD by season") 

#Label y axis 
plt.ylabel('Avg TDs', fontsize=18) 

#Limit range of axis labels to only show where data is 
plt.xlim(1966, 2014.5) 
plt.ylim(0,0.08) 

# create dashed lines 
plt.grid(axis='y',color='grey', linestyle='--', lw=0.5, alpha=0.5) 

# Change the size of tick labels for both axis 
# to a more readable font size 
plt.tick_params(axis='both', labelsize=14) 

# get rid of borders for our graph using seaborn's 
# despine function 
sns.despine(left=True, bottom=True) 

# plot the line for our graph 
plt.plot(x_values, y_values) 

plt.text(1966, -0.012, 
     'Primary Data Source: http://www.basketball-reference.com/draft/' 
     '\nAuthor: Joe T', 
      fontsize=12) 

# Display graph 
plt.show() 

を見下ろすよ小さなミスは、私は、xとyの値を印刷するとき、私が得るものであるだ:

[ 1970. 1971. 1972. 1973. 1974. 1975. 1976. 1977. 1978. 1979. 
    1980. 1981. 1982. 1983. 1984. 1985. 1986. 1987. 1988. 1989. 
    1990. 1991. 1992. 1993. 1994. 1995. 1996. 1997. 1998. 1999. 
    2000. 2001. 2002. 2003. 2004. 2005. 2006. 2007. 2008. 2009. 
    2010. 2011. 2012. 2013. 2014. 2015.] 

Season  
1970.0 11.625000 
1971.0  9.971429 
1972.0 11.645161 
1973.0  9.444444 
1974.0  8.947368 
1975.0 11.545455 
1976.0 10.750000 
1977.0  9.750000 
1978.0 13.090909 
1979.0 15.212121 
1980.0 16.194444 
1981.0 13.700000 
1982.0  9.700000 
1983.0 15.026316 
1984.0 13.658537 
1985.0 13.093023 
1986.0 13.048780 
1987.0 12.121951 
1988.0 11.931818 
1989.0 14.297297 
1990.0 14.486486 
1991.0 12.153846 
1992.0 11.285714 
1993.0 11.068182 
1994.0 12.813953 
1995.0 15.317073 
1996.0 13.431818 
1997.0 13.088889 
1998.0 12.812500 
1999.0 12.775510 
2000.0 13.886364 
2001.0 15.810811 
2002.0 14.755556 
2003.0 13.276596 
2004.0 17.050000 
2005.0 13.311111 
2006.0 13.666667 
2007.0 13.294118 
2008.0 15.073171 
2009.0 15.288889 
2010.0 16.204545 
2011.0 16.204545 
2012.0 18.871795 
2013.0 17.863636 
2014.0 18.428571 
2015.0 18.409091 
Name: TD, dtype: float64 
+0

あなたのプロットを保存することができますか? 'plt.show()'を 'plt.savefig( 'image.png')'に置き換えて、目的のプロットが表示されているかどうか確認してください。 –

+2

'x_values'と' y_values'を表示し、ここに投稿してください。軸の限界があなたの意図するものではないことが問題になるかもしれません。 – Anonymous

+0

@NickilMaveli画像を保存しましたが、プロットは表示されません。それは窓のように見える。軸ラベルのみ。私は、xとyの値私は 'X'と 'y'値のあなたの出力に混乱しているすべての – jhaywoo8

答えて

0

あなたの上部のy軸の上限は0.08であるが、あなたのyの値は、 9〜19の範囲である。

関連する問題