Guided Project: Visualizing Earnings Based On College Majors-review

Hi, Please review my guided project Visualizing Earnings Based On College Majors , please provide me a feedback to help me to improve
Thanks in advance

https://app.dataquest.io/m/146/guided-project%3A-visualizing-earnings-based-on-college-majors/1/introduction

Basics (1).ipynb (843.1 KB)

Click here to view the jupyter notebook file in a new tab

Your project looks great!! learn some code that i did not know.

I dont know how to position the ax1, ax2…, if I used fig,axes-plt.subplots() at beginning. The instruction taught us to do.ax.add_subplots(2,2,x)only, Can you help explain it? Thank you so much!

fig,axes=plt.subplots(nrows=3,ncols=2,figsize=(20,15))
ax1=recent_grads.plot(ax=axes[0,0],x="Sample_size",y="Median",kind="scatter")
ax2=recent_grads.plot(ax=axes[0,1],x="Sample_size",y="Unemployment_rate",kind="scatter")
1 Like

Hi, Thanks
i think this is the code you ask about:
fig,axes=plt.subplots(nrows=3,ncols=2,figsize=(20,15))
ax1=recent_grads.plot(ax=axes[0,0],x=“Sample_size”,y=“Median”,kind=“scatter”)
ax2=recent_grads.plot(ax=axes[0,1],x=“Sample_size”,y=“Unemployment_rate”,kind=“scatter”)
on the first line :
fig,axes=plt.subplots(nrows=3,ncols=2,figsize=(20,15))
you give nrows & ncols as parameter with specific numbers of rows & columns you need , here i assign nrows=3 & ncols=2
then:
ax1=recent_grads.plot(ax=axes[0,0],x=“Sample_size”,y=“Median”,kind=“scatter”)
you identify the plot location by axes[row_index,col_index] and assign it as parameter ax
kindly check this link:
https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.pyplot.subplots.html

wish it helpful

1 Like

Thank you for replying. I tried to change axes to ax. it does not work. Do I have to use axes?

ig,ax=plt.subplots(nrows=3,ncols=2,figsize=(20,15))
ax1=recent_grads.plot(ax[0,0],x=“Sample_size”,y=“Median”,kind=“scatter”)
ax2=recent_grads.plot(ax[0,1],x=“Sample_size”,y=“Unemployment_rate”,kind=“scatter”)```