Answers for "matplotlib removing ticks and spines"

0

matplotlib removing ticks and spines

import pandas as pd
import matplotlib.pyplot as plt

death_toll = pd.read_csv('covid_avg_deaths.csv')
fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4, ncols=1,
                                         figsize=(6,8))
axes = [ax1, ax2, ax3, ax4]

for ax in axes:
    ax.plot(death_toll['Month'], death_toll['New_deaths']) #create plot
    #remove ticks
    ax.set_yticklabels([])
    ax.set_xticklabels([])
    ax.tick_params(left=False,
    bottom=False)
    
    #remove spines
    for location in ['top', 'right','left','bottom']:
        ax.spines[location].set_visible(False)
plt.show()
Posted by: Guest on August-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language