If it's not important that the ticks update when panning/zomming (i.e. if the plot is not meant for interactive use), then you can manually set the tick locations with the axes.set_xticks()
method. In order to append one location (e.g. 271
), you can first get the current tick locations with axes.get_xticks()
, and then append 271
to this array.
A short example:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(np.arange(300))
# Get current tick locations and append 271 to this array
x_ticks = np.append(ax.get_xticks(), 271)
# Set xtick locations to the values of the array `x_ticks`
ax.set_xticks(x_ticks)
plt.show()
This produces
As you can see from the image, a tick has been added for x=271
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…