1

Im plotting a big timeserie with matplotlib, the x-axis is a list of datetime.datetime objects (the way matplotlib wants its x-axis) and a list of float values, I mean, a normal timeserie.

Using plot_date(dates,values) I get this plot, I checked the values are consecutive and its fine, enter image description here

Now I want to draw a line instead, using the same as above but plot_date(dates,values,fmt="-"): enter image description here

What is happening? Is it a bug? Im doing something wrong?

2
  • 3
    Your data should be sorted by date, I think... Commented Sep 5, 2013 at 14:13
  • So, what is happening? Are you getting zig zags? Commented Sep 5, 2013 at 14:15

1 Answer 1

2

zip the dates and values into a list of tuples, sort the (date, value) pairs, unzip the pairs with zip(*...), then plot:

dates, values = zip(*sorted(zip(dates,values)))
plot_date(dates,values, '-')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.