Python numpy-从图形中的x轴移除点

Python numpy-从图形中的x轴移除点,python,numpy,Python,Numpy,我有以下代码: import numpy as np %matplotlib notebook import matplotlib.pyplot as plt import ipywidgets as widgets from maux import init_subplot, smart_ticklabel from mtest import true_false_test plt.rcParams.update({'figure.max_open_warning': 0}) X = np

我有以下代码:

import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
import ipywidgets as widgets
from maux import init_subplot, smart_ticklabel
from mtest import true_false_test
plt.rcParams.update({'figure.max_open_warning': 0})


X = np.linspace(-np.pi, np.pi, 2*4*100+1)

fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, sharex=True, sharey=True)
fig.set_size_inches(9, 10)

init_subplot(ax1)

xtick_numerators = range(-6, 6+1)
ax1.set_xticks([n * np.pi / 6 for n in xtick_numerators])
ax1.set_xticklabels([smart_ticklabel(n, r"\pi", 6)  for n in xtick_numerators])

ax1.set_ylim(-3.4, 4.4)

def df(X): return ((2 * np.sin(2*X)*np.cos(2*X)) / np.abs(np.sin(2*X))) +1 
dX = X 

ax1.plot(dX, df(dX), label="derivation")

fig.show()

问题是,在图形中,有一些线不应该出现在轴x上,例如点2/π上;0; π/2. 我不知道如何移除它们。有什么办法吗

智能标签也未定义。如果不包含这些东西的代码,就不可能获得完整的图片。注释代码中的第6行并定义一个简单的
smart\u ticklab
函数似乎没有显示任何内容unexpected@ZaccharieRamzi自从我发表评论以来,这段代码已经被编辑过了。我想知道我是否应该删除我的评论,因为我编辑的代码不再有效。希望现在对您有用。@dfps12什么是
maux
mtest
?请务必阅读以了解如何编写完美的最小工作示例。