Answers for "matplotlib remove x ticks"

0

matplotlib remove ticks and lines

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1],[1])
ax.tick_params(axis=u'both', which=u'both',length=0)
plt.show()
Posted by: Guest on April-07-2020
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