0

Below is my dataframe:

login_data_df_jan_weekly
Out[22]:

login_time  login_counts

2010-01-03  1010
2010-01-10  2917
2010-01-17  3022
2010-01-24  2851
2010-01-31  3196

I am trying to plot it using matplotlib.pyplot.subplots()

  import matplotlib.pyplot as plt
pd.set_option('display.mpl_style', 'default')
%matplotlib inline
fig, ax1 = plt.subplots()
ax1.plot(login_data_df_jan_weekly.index, login_data_df_jan_weekly['login_counts'])
ax1.set_xlabel('Date_time')
ax1.set_ylabel('login_counts')
plt.show()
plt.rcParams['figure.figsize'] = 44,20

But my dataframe variables on x axis appear unclear and hard to read. how do I fix this?

graph

optimus_prime
  • 817
  • 2
  • 12
  • 34
  • a quick way to handle this is to you use `plot` attribute of the dataframe: `login_data_df_jan_weekly.plot.line(y='login_counts', ax=ax1)` – Paul H Apr 11 '17 at 01:08
  • What you are talking about are called `ticks`. You can choose how many to display, like in this [example](http://stackoverflow.com/questions/6682784/how-to-reduce-number-of-ticks-with-matplotlib). Have a look and see if it applies to your situation. – gnikit Apr 11 '17 at 01:16
  • with the first suggestion by @PaulH , I get date_time values that were never part of the original columns and with the second approach the issue is I need all 5 ticks that I have for 5 date time values – optimus_prime Apr 11 '17 at 01:26
  • you can rotate your tick labels, just google it... – Julien Apr 11 '17 at 01:28
  • is `longin_time` in the index? if not, pass it (the string) as `x` to the plotting method. – Paul H Apr 11 '17 at 02:20

1 Answers1

0

Is this what you are looking for?

plt.xticks(rotation=45)

This basically rotates x-axis label by 45 degrees and you would be able to see them clearly.