dorien dorien - 8 months ago 30
Python Question

Plot list of lists (which different length) in a plot in python

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)

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


But alas.


What about just doing

data = [[4,3,4],[2,3],[5,6,4,5]]
for d in data: