0
$\begingroup$

I am new to python programming. As part of a data analysis project, I am trying to get a scatter plot of Salary vs Wins for each year of 4 consecutive years (so I am trying to get 4 different scatter plots, one for each year). I am using the following code:

teamName = 'OAK'
years = np.arange(2000,2004)
for yr in years:
    df = joined[joined['yearID']==yr]
    plt.scatter(df['salary']/1e6,df['W'])
    plt.title('Wins vs Salaries in year' + str(yr))
    plt.xlabel('Total Salary (in millions)')
    plt.ylabel('Wins')
    plt.xlim(0,180)
    plt.ylim(30,130)
    plt.grid()
    plt.show()

However, I am only getting one plot corresponding to 2003.

Can anyone point out the mistake ?

Thanks

$\endgroup$

1 Answer 1

0
$\begingroup$

All of your plots are appearing on top of each other. You need to invoke plt.subplot(xxx) before you create each plot. For info on how the xxx command works, go to the MATLAB documentation.

You might end up with multiple figures - see this page for info about that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.