0

Why doesn't ax1.set_yticks([]), plt.yticks([]), plt.setp(ax1.get_yticklabels(),visible=False) plt.gca().set_yticks([]), nor plt.tick_params(left=False,bottom=False,labelleft=False,abelbottom=False) remove the tick numbers in this plot?

import numpy as np
import matplotlib.pyplot as plt
xscalespace=np.logspace(1, 6, num=6)
fig, (ax1, ax2) = plt.subplots(2, sharey=False, figsize=(5,5))
frequenz = np.exp(np.linspace(0,1,11)*20)#dummy lines doesn't matter
amplitude   = np.exp(-np.linspace(0,1,11))#they don't matter
plt.sca(ax1)
plt.xscale('log')
plt.yscale('log')
ax1.plot(frequenz,amplitude/15,"*",label="plot",color="green")
plt.legend()
plt.grid()
plt.ylim(0.1, 1) 
ax1.set_yticks([])
plt.yticks([])
plt.setp(ax1.get_yticklabels(),visible=False)
plt.gca().set_yticks([])
plt.tick_params(left=False,
                bottom=False,
                labelleft=False,
                labelbottom=False)

The reason I ask is, I am setting my own labels but they create conflict with these irremovable labels. And I've tried everything, but nothing seems to work.

this is what I get

Rainb
  • 1,965
  • 11
  • 32

1 Answers1

0

You can try specifying xticks and xticklabels from the setp function to force label deletions

     plt.setp(ax1, xticks=[1,2,3,4,5],
     xticklabels=['','','','',''],
     yticks=[1,2,3,4,5],
     yticklabels=["",'','',''])
  • with xticks / yticks you have to specify the values ​​of your x and y axis from which you want to remove the labels, then with xticklabels you say that these labels must be of zero value with '' (sorry for English I am French) – Raphaël Gervillié Jan 18 '21 at 15:58