# Padding lists for accurate plotting

I have the following data which is in the form of irregular/non rectangular arrays

list1 = {{1}, {2}, {3}, {4}, {5, 6, 7}, {8, 9, 10}, {11}, {12}}


To transpose it for plotting, I have to use (because of the irregular shape)

list2 = Flatten[list1, {{2}, {1}}]


This is now a $$3\times1$$ column. I want to plot this data, So I use the ListLinePlot as

ListLinePlot[list2, DataRange -> {1, 3}, Frame -> True]


The three rows are plotted as three curves, but the problem is that the upper two curves which correspond to the second and third row of list2 also start from 1 on the x-axis.? Shouldn't they start from 2 instead of 1? I thought I could use PadLeft or PadRight with empty entries {} to the left or right of the last two (2 element) rows of list2 (to make them 6 element rows, like the first row of list2) to force the two curves to start from 2, but I failed. Could someone tell any workaround?

• Does ListLinePlot[Transpose[PadRight[list1]], DataRange -> {1, 3}] do what you want? Mar 14 '19 at 6:00
• @J.M.isslightlypensive Thanks. But it gives zeros on right and left which actually do not do the trick, however, if they are somehow empty, would do the trick.
– AtoZ
Mar 14 '19 at 6:20

ListLinePlot[Transpose[PadRight[list1, Automatic, Null]],