4

I have two lists i'm doing a basic line chart with in ipython notebook. Should be basic, but I keep getting a screwed up x-axis like this... it should start with Saturday.

enter image description here

What's wrong with my code that's making my x-axis label all messed up? It should start with Saturday, the first value in my date_list. (ignore the y-axis values here, i just made count_list values for this example.)

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

count_list = [5,7,2,3,1,7,3]
date_list = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']

fig=plt.figure(figsize=(12,3.5))
ax=fig.add_subplot(111)
ticknumbs = np.arange(7)
ax.plot(ticknumbs, count_list, color='r', linewidth=1.0)
ax.set_xticklabels(date_list, rotation = 45) #WHHHHY ARENT U WORKING
ax.margins(x=0.05, y=0.05)

1 Answer 1

3

Take out the ax_margins() line. You're clipping your first data point right off.

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

dang, knew it was simple. what should i do if i want some extra space that the margins provides? CAN I HAVE IT ALL.
The plot looks fine without padding to me. Perhaps you want to make the axis smaller within the figure? (don't know how that works with the notebook).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.