python - showing specific xtick in matplotlib -


so have graph runs on order of magnitude 10000 time steps, , have lot of data points , xticks spaced pretty far apart, cool, to show on xaxis point @ data being plotted. in case xtick want show 271. there way "insert" 271 tick onto x axis given know tick want display?

if it's not important ticks update when panning/zomming (i.e. if plot not meant interactive use), can manually set tick locations axes.set_xticks() method. in order append 1 location (e.g. 271), can first current tick locations axes.get_xticks(), , append 271 array.

a short example:

import matplotlib.pyplot plt import numpy np  fig = plt.figure()  ax = fig.add_subplot(111) ax.plot(np.arange(300))  # current tick locations , append 271 array x_ticks = np.append(ax.get_xticks(), 271)  # set xtick locations values of array `x_ticks` ax.set_xticks(x_ticks)  plt.show() 

this produces

axes added tick location

as can see image, tick has been added x=271.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -