जवाबों:
इस tick_params
तरह से सामान के लिए विधि बहुत उपयोगी है। यह कोड मेजर और माइनर टिक्स को बंद कर देता है और एक्स-एक्सिस से लेबल हटा देता है।
from matplotlib import pyplot as plt
plt.plot(range(10))
plt.tick_params(
axis='x', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom=False, # ticks along the bottom edge are off
top=False, # ticks along the top edge are off
labelbottom=False) # labels along the bottom edge are off
plt.show()
plt.savefig('plot')
plt.clf()
plt.tick_params(axis='both', which='both', bottom='off', top='off', labelbottom='off', right='off', left='off', labelleft='off')
axes
एक ही tick_params
विधि है।
matplotlib
, आप बदलना चाहिए 'on'
साथ True
और 'off'
साथ False
।
ओपी के लिए पूछ रहा था बिल्कुल नहीं, लेकिन सभी कुल्हाड़ियों लाइनों, टिक और लेबल को निष्क्रिय करने का एक सरल तरीका बस कॉल करना है:
plt.axis('off')
ax.axis('off')
मौजूदा एक्सिस उदाहरण पर होगा ।
वैकल्पिक रूप से, आप एक खाली टिक स्थिति और लेबल को पास कर सकते हैं
# for matplotlib.pyplot
# ---------------------
plt.xticks([], [])
# for axis object
# ---------------
# from Anakhand May 5 at 13:08
# for major ticks
ax.set_xticks([])
# for minor ticks
ax.set_xticks([], minor=True)
ax
तो कहें , तो आप उपयोग कर सकते हैं:ax.set_xticks([], [])
ax.set_xticks([])
प्रमुख टिक के लिए, ax.set_xticks([], minor=True)
मामूली टिक के लिए। के साथ समकक्ष pyplot
हैं plt.xticks([])
और plt.xticks([], minor=True)
।
यहाँ एक वैकल्पिक समाधान है जो मुझे matplotlib मेलिंग सूची में मिला है :
import matplotlib.pylab as plt
x = range(1000)
ax = plt.axes()
ax.semilogx(x, x)
ax.xaxis.set_ticks_position('none')
जॉन विनयार्ड द्वारा दिए गए की तुलना में एक बेहतर और सरल, समाधान है। उपयोग करें NullLocator
:
import matplotlib.pyplot as plt
plt.plot(range(10))
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.show()
plt.savefig('plot')
उम्मीद है की वो मदद करदे।
axins.xaxis.set_major_locator(plt.NullLocator())
, axins
वह वस्तु कहाँ से लौटाया जाता है axins = zoomed_inset_axes()
( जिससे आयात किया गया फ़ंक्शन mpl_toolkits.axes_grid1.inset_locator
)।
यह स्निपेट केवल xticks को हटाने में मदद कर सकता है।
from matplotlib import pyplot as plt
plt.xticks([])
यह स्निपेट xticks और yticks दोनों को हटाने में मदद कर सकता है।
from matplotlib import pyplot as plt
plt.xticks([]),plt.yticks([])
# remove all the ticks (both axes), and tick labels on the Y axis
plt.tick_params(top='off', bottom='off', left='off', right='off', labelleft='off', labelbottom='on')
ax.tick_params()
off
और on
पदावनत किया जाता है। MatplotlibDeprecationWarning: Passing one of 'on', 'true', 'off', 'false' as a boolean is deprecated; use an actual boolean (True/False) instead.
आप में से जो सभी टिक्स और लेबल को बंद करने के लिए एक छोटी कमांड की तलाश कर रहे हैं, उनके साथ ठीक होना चाहिए
plt.tick_params(top=False, bottom=False, left=False, right=False, labelleft=False, labelbottom=False)
जो bool
संस्करण matplotlib> = 2.1.1 के बाद से संबंधित मापदंडों के लिए टाइप करने की अनुमति देता है
कस्टम टिक सेटिंग्स के लिए, डॉक्स मददगार हैं:
https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.tick_params.html
ax.set_xticks([], [])
और यह हल हो गया है ...