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() 

enter image description here


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -