Making ticks invisible pandas hist graph using pandas dataframe.hist api


Making ticks invisible pandas hist graph using pandas dataframe.hist api



I have tried everything using kwargs, set_visible, and other suggestions given in the docs but have not been able to make x_ticks disappear. Can you guys help me do this.



One of the approaches suggested is following but it complains ax is numpy array and that has no affect is this


fig, ax = plt.subplots(1, 1)
ax.get_xaxis().set_visible(False) # Hide Ticks
ns = dummy.hist(bins=20, ax=ax)



This produces following - as you can see x ticks make the graph unreadable.



enter image description here



Solved



ns is of type ndarray, the shape of that is determined by the default layout: in my case it is (3,2). I had to call set_xticks on individual subplots as shown below


rows, cols = ns.shape
for r in range(rows):
for c in range(cols):
ns[r,c].set_xticks()



enter image description here





This is related to matplotlib. Added tag. Possible duplicate of Remove xticks in a matplotlib plot?
– Anton vBR
Jul 1 at 13:58






Those are not the ticks. Those are ticklabels. Consider setting fewer ticks.
– Andras Deak
Jul 1 at 14:02






Can you try using dummy.hist() to get xticks to disappear. I have tried dummy.plot(kind='hist', subplots=True) but that call is considerably slower for my data.
– smishra
Jul 1 at 14:07





@AntonvBR, Pandas dataframe's plot api may be using matplotlib under the covers but my question is specific to using data frame.hist and not matplotlib.plt.
– smishra
Jul 1 at 14:17





@smishra Sure, but to manipulate the graphs you are using the matplotlib functions.
– Anton vBR
Jul 1 at 14:27









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

What's the difference between DDS and SOME/IP?

How to make file upload 'Required' in Contact Form 7?