Reputation: 51
I have data divided into different periods of time. The time-series is continuous for eg(one data set is for february then next on April and next in Jan 2016) But how can I reduce the gap of the year 2015 in between> It really just wastes the space and shrinks the graph
I can plot them together like the image below. Any way to remove the time-stamps in between?
Upvotes: 2
Views: 3898
Reputation: 4744
If you are using a pandas DataFrame then this should work and it is a little tidier than the above answer:
fig = plt.figure()
fig, axes = plt.subplots(1, 3, sharey=True)
for (col, data), ax, c in zip(df.iteritems(), axes):
data.dropna().plot(ax=ax, rot=30, legend=True)
Upvotes: 0
Reputation: 51
I found a solution, which isn't exactly what I was looking for but fulfills the purpose. I modified the solution posted of this link:
fig=plt.figure()
fig,(ax,ax2,ax3) = plt.subplots(1,3,sharey=True)
fig.subplots_adjust(wspace=0.05)
fig.set_size_inches(20, 3, forward=True)
ax.plot(healthyde['timestamp'],healthyde['value'],label='healthy',color='g')
ax2.plot(healthynde['timestamp'],healthynde['value'],label='detection',color='y')
ax3.plot(healthylde['timestamp'],healthylde['value'],label='fault',color='r')
ax.set_xlim(healthyde['timestamp'].iloc[0], healthyde['timestamp'].iloc[-1] )
ax2.set_xlim(healthynde['timestamp'].iloc[0], healthynde['timestamp'].iloc[-1] )
ax3.set_xlim(healthylde['timestamp'].iloc[0], healthylde['timestamp'].iloc[-1] )
labels = ax.get_xticklabels()
for label in labels:
label.set_rotation(30)
labels = ax2.get_xticklabels()
for label in labels:
label.set_rotation(30)
labels = ax3.get_xticklabels()
for label in labels:
label.set_rotation(30)
ax.legend()
ax2.legend()
ax3.legend()
plt.show()
Output:
Upvotes: 2