I have two nested lists with the values for the x-axis and y-axis that I want to plot in the same figure.
Whith a for loop to iterate through the values produces the expected plot, but for large lists is relatively slow. So I was looking for the same functionality but without the loop, which I thought matplotlib could handle, but the plot is not what I was expecting.
Here's the code:
import matplotlib.pyplot as plt
xs = [[11, 20], [31, 31], [32, 33]]
ys = [[1, 10], [3, 4], [6, 10]]
With a loop the figure is OK:
fig, ax = plt.subplots()
for i, x in enumerate(xs):
ax.plot(x, ys[i])
plt.show()
But just giving the lists to matplotlib, doesn't generate the same plot:
fig, ax = plt.subplots()
ax.plot(xs, ys)
plt.show()
What would be the proper way for doing this whithout a loop?