I'm trying to plot a 2-D image with matplotlib, which expects data points in nested list format. I've got as far as a very neat, idiomatic way to generate this:
zs = [[cost_at(x, y) for x in x_range] for y in y_range]
plt.contourf(x_range, y_range, zs, 1000)
And it works - for small data. However, I now need to do exactly the same thing except for X and Y range too big for the full nested list to fit in memory. It seems to me it should be possible to call the API with lazy lists that hopefully would be adequate substitutes, assuming the library accesses them by iterators.
What's the way to do the above except with lazy lists?