在我的代码matplotlib库中得到了这个:
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_position('zero')
ax.spines['left'].set_position('zero')
它告诉我:
我期待斧头被砍!如何获得切割轴?
这是完整的代码:
import matplotlib.pyplot as plt
pgcd = lambda a, b: a if b==0 else pgcd(b, a%b)
def EKG(n):
ekg = [1, 2]
i = 2
while i < n:
j = 1
while j in ekg or pgcd(j, ekg[i-1]) == 1:
j += 1
ekg.append(j)
i += 1
return ekg
supEKG = lambda n: sum(a>n for a in EKG(n))
arr = []
r = range(3, 100)
for n in r:
arr.append(supEKG(n))
f = plt.figure()
ax = f.add_subplot(1,1,1)
ax.plot(r, arr)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_position('zero')
ax.spines['left'].set_position('zero')
plt.show()
相关分类