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
> 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