plot_date + xdata & ydata must be same len

Re: [Matplotlib-users] plot_date + xdata & ydata must be same len

I actually got a work around now. Thanks for the follow.

Chris Brinley (chris.brinley@…1265…)

Orbitz - Operations

Phone: 312-894-4787

Cell: 312-479-8193

Pager: 866-292-3508


-----Original Message-----

From: John Hunter

To: Brinley, Chris


Sent: Fri Sep 15 11:29:07 2006

Subject: Re: [Matplotlib-users] plot_date + xdata & ydata must be same len

> Hi, I am having trouble getting a variation of the

> tutorial plot_date() to work. I get the classic:

> RuntimeError: xdata and ydata must be the same length.

Hmm, didn’t know this had achieved classic status…

> The tutorial on the matplotlib site shows how to plot

> dates using whole days. I am plotting using multiple

> days showing each minute of the day.

> Before I run plot_date I setup to datetime vars and

> subtract them to get the timedelta so.. timedelta =

> enddate - startdate.

> I then use drange(startdate, enddate, timedelta)

This doesn’t look right, since your delta equals the entire range.

Usually you want your delta to be smaller.

> I pass this range into the plot_date function with my y

> axis data, which I have confirmed is numeric and the

> same number of entries as the number of datetimes I want

> to plot.

Maybe you made a mistake here? It sometimes happens when working

interactively that you add some bad data to a plot, realize your

mistake, then add good data, but still see the error. When this

happens, it is usually because your “hold” state is on and the

previous data is still in your plot. You can clear the figure with


If you are still having a problem, post a complete example that we

can run.

> Clearly I am incorrectly telling plotlib the intervals

> of time I want to plot. What is the best way to plot out

> an interday chart that has ticks for each min?

from matplotlib.dates import MinuteLocator

every minute


or every 5 minutes


You’ll probably also want to set the Formatter – see the user’s guide

chapter on tick locating and formatting and also

and these examples

mpl/examples> grep -l Locator *.py