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
음모를 저장할 수 있습니까? 'plt.show()'를'plt.savefig ('image.png')'로 바꾸고 의도 한 플롯이 나타나는지보십시오. –
'x_values'와'y_values'를 출력하고 여기에 게시하십시오. 축 한계가 의도 한 것이 아닌 문제 일 수 있습니다. – Anonymous
@NickilMaveli 이미지를 저장했지만 줄거리가 표시되지 않습니다. 그것은 마치 창문처럼 보입니다. 축 레이블 만. x와 y 값을 더했습니다. – jhaywoo8