dorien - 1 year ago 77

Python Question

I have a list of lists, each of these internal lists has a different length, and I would like to show them in a graph.

They would look like this:

`data = [[4,3,4],[2,3],[5,6,4,5]]`

for each of these, I would like to plot them against there index (x-axis), so for instance, for the first list: (0,4),(1,3),(2,4)

If my lists would have been the same length, I would have converted them to a numpy array and just plotted them:

`data_np = np.vstack(data)`

plot_data_np = np.transpose(data_np)

plt.plot(plot_data_np)

However, there is this length issue... In a hopeful attempt I tried:

`plt.plot(data)`

But alas.

Answer Source

What about just doing

```
data = [[4,3,4],[2,3],[5,6,4,5]]
for d in data:
plt.plot(d)
```

?