python - Removing all but one tick on x-axis -
i have graph tick remove ticks , corresponding labels bar first tick , label on x-axis. how go this?
import pylab import numpy np import matplotlib.pyplot plt a=np.linspace(0,10,10000) print def f(x): return 1/(1-(x**2)*np.log((1/(x**2)+1))) b=f(a) fig, ax = plt.subplots(1) ax.plot(b,a) pylab.xlim(0.5, 5) pylab.ylim(0, 1.5) fig.show()
you can use ax.set_xticks([1])
set 1 xtick
@ 1,0.
also, there's no need import both pylab
, matplotlib.pyplot
. the recommended way import matplotlib.pyplot
, use axes
methods. e.g., can use ax.set_xlim
instead of pylab.xlim
.
here's full script , output plot:
import numpy np import matplotlib.pyplot plt a=np.linspace(0,10,10000) print def f(x): return 1/(1-(x**2)*np.log((1/(x**2)+1))) b=f(a) fig, ax = plt.subplots(1) ax.plot(b,a) ax.set_xlim(0.5, 5) ax.set_ylim(0, 1.5) ax.set_xticks([1]) plt.show()
Comments
Post a Comment