-1

I have a function that takes a month and year and I want to set the xticks of a plot to the month and year that is inputted.

For example if user enters 5 as the month and 2019 as the year I want to make the first xtick 5/2018, the second one 6/2018, and so on. If it reaches 12/2018, the next tick should be 1/2019.

I was reading about datetime but I'm not sure how I would use it for this problem.

I tried this but it doesn't work and I'm pretty sure this is not the way to tackle this.

cityPlot(self, year, month):

   myDates = [datetime(int(year), month, 1]
   plt.plot(myDates) 
1
  • 1
    where is you code? Commented Oct 14, 2019 at 21:22

1 Answer 1

0

matplotlib.pyplot.xticks is probably what are you looking for. You should look at this too

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

Comments

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.