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.title('Wins vs Salaries in year' + str(yr))
    plt.xlabel('Total Salary (in millions)')

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

Can anyone point out the mistake ?



1 Answer 1


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.


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.