0

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

smishra
  • 3,122
  • 29
  • 31
  • This is related to matplotlib. Added tag. Possible duplicate of [Remove xticks in a matplotlib plot?](https://stackoverflow.com/questions/12998430/remove-xticks-in-a-matplotlib-plot) – Anton vBR Jul 01 '18 at 13:58
  • Those are not the ticks. Those are ticklabels. Consider setting fewer ticks. – Andras Deak -- Слава Україні Jul 01 '18 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 01 '18 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 01 '18 at 14:17
  • @smishra Sure, but to manipulate the graphs you are using the matplotlib functions. – Anton vBR Jul 01 '18 at 14:27

0 Answers0