0

I am trying to plot a count of events in a continuous time manner. For that I have used time series index with a minute level precision and want to visualise the count.

Code used for the plot is given below.

import numpy as np
import pandas as pd

y1 = np.random.randint(20, size=10000)
y2 = np.random.choice(y1,4321) # To match the time series index length

x1 =  pd.date_range('2010-01-15 00:00:00', '2010-01-18 00:00:00', freq='T' ) 
# date time with mins precision
x2 = pd.DataFrame(x1, columns=['Date_time_ref']).set_index('Date_time_ref', drop=True)
x2['values'] = y2

#plot the data
ax = x2.plot(kind='line', figsize=(18,6),legend=None)
#format x-axis labels
ax.set_xticklabels(x2.index.strftime('%Y-%m-%d %H:%M'), rotation=90)
plt.xlabel('Date - Hour - Min');

The x-axis data span from '2010-01-15 00:00:00' to '2010-01-18 00:00:00', but only first few values are displayed on the x-axis. What is the best way to resolve the issue?. Thanks in advance

plot given below

Trenton McKinney
  • 43,885
  • 25
  • 111
  • 113
SriHari
  • 1
  • 2

0 Answers0