python - How can I remove xtics from an axis in matplotlib? -
this question has answer here:
i'm using subplots in matplotlib. since of subplots have same x-axis, want label x-axis on bottom plot. how can remove xtics 1 axis?
dan, if you've set plots in oop way using
import matplotlib.pyplot plt fig, ax_arr = subplots(3, 1, sharex=true)
then should easy hide x-axis labels using like
plt.setp([a.get_xticklabels() in f.axes[:-1]], visible=false) # or plt.setp([a.get_xticklabels() in ax_arr[:-1]], visible=false)
but check out this link , of further down examples prove useful.
edit:
if can't use plt.subplots()
, i'm still assuming can do
import matplotlib.pyplot plt fig = plt.figure() ax1 = fig.add_subplot(211) ax2 = fig.add_subplot(212) ax1.plot(x1, y1) ax2.plot(x2, y2) plt.setp(ax1.get_xticklabels(), visible=false)
if have more 2 subplots, such
ax1 = fig.add_subplot(n11) ax2 = fig.add_subplot(n12) ... axn = fig.add_subplot(n1n) plt.setp([a.get_xticklabels() in (ax1, ..., axn-1)], visible=false)
Comments
Post a Comment