<matplotlib.axes._subplots.AxesSubplot at 0x108bb10f0>
# ax comes from the plottingax=df.groupby("Continent")['life_expectancy'].median().plot(kind='barh')ax.set_ylabel("")
<matplotlib.text.Text at 0x1091551d0>
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(10,5))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax)ax.set_ylabel("")
<matplotlib.text.Text at 0x108f617b8>
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax)ax.set_ylabel("")ax.grid(True)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='r',linestyle='-',linewidth=2)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='MidnightBlue',linestyle='-',linewidth=0.5)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='MidnightBlue',linestyle=':',linewidth=0.5)ax.set_axisbelow(True)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='MidnightBlue',linestyle=':',linewidth=0.5)ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='MidnightBlue',linestyle=':',linewidth=0.5)ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)plt.tick_params(axis='x',# changes apply to the x-axiswhich='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offbottom='off',# ticks along the bottom edge are offlabeltop='on',# top label is onlabelbottom='on')# bottom label is on
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# When plotting the grid, you can send it options!ax.grid(color='MidnightBlue',linestyle=':',linewidth=0.5)ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='on',# top label is onlabelbottom='on')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(color='MidnightBlue',linestyle=':',linewidth=0.5)ax.yaxis.grid(color='pink',linestyle="-.",linewidth=5)ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='on',# top label is onlabelbottom='on')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='on',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,7))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=1)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,7))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=0.5)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)ax.set_xlim((0,79))
(0, 79)
df['life_expectancy'].median()
70.04150000000001
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)# Get rid of this line, and the minor grid lines disappear#ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)# Use ax.annotate to add textax.annotate(s="Median life expectancy, 70 years",xy=(71,0),color='darkred')ax.set_xlim((0,79))
(0, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)# Get rid of this line, and the minor grid lines disappear#ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)# Use ax.annotate to add textax.annotate(s="Median life expectancy, 70 years",xy=(71,0),color='darkred')ax.set_xlim((30,79))
(30, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',color='gray',ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)# Get rid of this line, and the minor grid lines disappear#ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)# Use ax.annotate to add textax.annotate(s="Median life expectancy, 70 years",xy=(71,0),color='darkred')ax.set_xlim((30,79))
(30, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',color=['gray','darkred','gray','gray','gray','darkred'],ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)# Get rid of this line, and the minor grid lines disappear#ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)# Use ax.annotate to add textax.annotate(s="Median life expectancy, 70 years",xy=(71,0),color='darkred')ax.set_xlim((30,79))
(30, 79)
# Initialize the plot first, take the axfig,ax=plt.subplots(figsize=(7,3))# Pass the ax to the .plot functiondf.groupby("Continent")['life_expectancy'].median().plot(kind='barh',color=['darkred','gray','gray','gray','darkred','gray'],ax=ax,linewidth=0,width=0.4)ax.set_ylabel("")# ax.xaxis.grid takes all the same options as ax.grid# but only applies to one of the axesax.xaxis.grid(which="major",color='MidnightBlue',linestyle=':',linewidth=1)# Turn on a minor grid, a smaller grid, a more frequent gridax.xaxis.grid(which="minor",color='darkred',linestyle=":",linewidth=0.5)# Get rid of this line, and the minor grid lines disappear#ax.minorticks_on()ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['bottom'].set_visible(False)ax.spines['left'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labeltop='on',# top label is onlabelbottom='on')# bottom label is onplt.tick_params(which='minor',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabeltop='off',# top label is onlabelbottom='off')# bottom label is onmedian=df['life_expectancy'].median()ax.plot([median,median],[-1,10],c='red',linestyle="-",linewidth=0.5)# Use ax.annotate to add textax.annotate(s="Median life expectancy, 70 years",xy=(71,0),color='darkred')ax.set_xlim((30,79))plt.savefig("life.pdf",transparent=True)
FiveThirtyEight scatterplot of countries’ GDP and life expectancy
fig,ax=plt.subplots()# I already made a chart, I'm going to send it to youdf.plot(kind='scatter',x='GDP_per_capita',y='life_expectancy',ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x10ac20208>
fig,ax=plt.subplots()fig.set_facecolor('lightgray')ax.set_axis_bgcolor('lightgray')ax.set_prop_cycle('color',['pink','purple','red','deeppink','lightcoral','magenta'])ax.grid(linestyle='-')ax.spines['left'].set_visible(False)ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)ax.spines['bottom'].set_visible(False)plt.tick_params(which='major',# both major and minor ticks are affectedtop='off',# ticks along the top edge are offleft='off',# ticks along the right edge are offright='off',# ticks along the right edge are offbottom='off',# ticks along the bottom edge are onlabelright='off',labelleft='on',labeltop='off',# top label is onlabelbottom='on')# bottom label is onforcontinent,selectionindf.groupby("Continent"):ax.plot(selection['GDP_per_capita'],selection['life_expectancy'],label=continent,marker='o',linestyle='',markeredgewidth=0)ax.legend(loc='lower right')ax.set_ylim((30,85))
(30, 85)
Want to hear when I release new things? My infrequent and sporadic newsletter can help with that.