hselbie
hselbie

Reputation: 1879

Extend matplotlib line plot across chart

I've created this plot, but it doesn't extend all the way across the figure for some reason. Can anyone help explain why?

Chart = enter image description here

Code =

fig, ax = plt.subplots()
ax.plot(trip.index, trip.gas, marker='.',linestyle='-')

plt.xticks(np.arange(min(trip.index), max(trip.index), 7))
ax.set_xticklabels(map(str, ax.get_xticks()/7))
plt.xlabel('Week #')
plt.ylabel('Trip Cost ($)')

Upvotes: 1

Views: 524

Answers (1)

Christoph
Christoph

Reputation: 1557

Matplotlib tends to include some space around the data. If you don't want that, you can adjust the axis ranges manually. This can be done via

plt.xlim(min(trip.index),max(trip.index))

Upvotes: 1

Related Questions