matplotlib removing ticks and spines

Solutions on MaxInterview for matplotlib removing ticks and spines by the best coders in the world

showing results for - "matplotlib removing ticks and spines"
Hugh
14 May 2020
1import pandas as pd
2import matplotlib.pyplot as plt
3
4death_toll = pd.read_csv('covid_avg_deaths.csv')
5fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4, ncols=1,
6                                         figsize=(6,8))
7axes = [ax1, ax2, ax3, ax4]
8
9for ax in axes:
10    ax.plot(death_toll['Month'], death_toll['New_deaths']) #create plot
11    #remove ticks
12    ax.set_yticklabels([])
13    ax.set_xticklabels([])
14    ax.tick_params(left=False,
15    bottom=False)
16    
17    #remove spines
18    for location in ['top', 'right','left','bottom']:
19        ax.spines[location].set_visible(False)
20plt.show()
21
22