Reputation: 11691
I am having an issue where two sets of x-ticks and labels are showing (and overlapping with each other). One set is the correct set I want to be there and the other just won't go away...
Here is a re-produceable example:
import datetime
import pandas as pd
import random
import matplotlib.pyplot as plt
start_date = datetime.datetime(2015, 6, 1)
df = []
for i in range(20):
df.append({
'Day': start_date + datetime.timedelta(days=i),
'Val': random.random()
})
df = pd.DataFrame(df)
fig, ax = plt.subplots(figsize=(12,12))
ax = df.plot(ax=ax, x='Day', y='Val')
ax.xaxis.set_major_locator(mdates.AutoDateLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%B %d'))
fig.autofmt_xdate()
And it creates the following graph
The rotated tick labels are what I am looking for and in the proper location. However there are still digits that overlapping there that I can't seem to get rid of. I have tried removing ticks and labels before applying the formatter, as well as playing with grid options. Ultimately I either get nothing to show up or both sets of labels. Any help is greatly appreciated
EDIT In my experimentation I have found that if I use
ax.set_xticks([])
ax.set_xticklabels([])
after I set the formatter. I get rid of my "good" labels and I'm still left with the ones I don't want! How do I get rid of these!?
Upvotes: 2
Views: 309